< Summary

Class:Cysharp.Threading.Tasks.UniTask
Assembly:UniTask
File(s):File 1: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Bridge.cs
File 2: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.cs
File 3: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs
File 4: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs
File 5: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Run.cs
File 6: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Threading.cs
File 7: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WaitUntil.cs
File 8: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAll.cs
File 9: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAll.Generated.cs
File 10: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAny.cs
File 11: C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAny.Generated.cs
Covered lines:104
Uncovered lines:1491
Coverable lines:1595
Total lines:14366
Line coverage:6.5% (104 of 1595)
Covered branches:0
Total branches:0
Covered methods:18
Total methods:268
Method coverage:6.7% (18 of 268)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
File 1: ToCoroutine(...)0%0000%
File 2: UniTask(...)0%000100%
File 2: GetAwaiter()0%000100%
File 2: SuppressCancellationThrow()0%0000%
File 2: implicit operator System.Threading.Tasks.ValueTask(...)0%0000%
File 2: ToString()0%0000%
File 2: Preserve()0%0000%
File 2: AsAsyncUnitUniTask()0%0000%
File 2: AsyncUnitSource(...)0%0000%
File 2: GetResult(...)0%0000%
File 2: GetStatus(...)0%0000%
File 2: OnCompleted(...)0%0000%
File 2: UnsafeGetStatus()0%0000%
File 2: GetResult(...)0%0000%
File 2: IsCanceledSource(...)0%0000%
File 2: GetResult(...)0%0000%
File 2: GetResult(...)0%0000%
File 2: GetStatus(...)0%0000%
File 2: UnsafeGetStatus()0%0000%
File 2: OnCompleted(...)0%0000%
File 2: MemoizeSource(...)0%0000%
File 2: GetResult(...)0%0000%
File 2: GetStatus(...)0%0000%
File 2: OnCompleted(...)0%0000%
File 2: UnsafeGetStatus()0%0000%
File 2: Awaiter(...)0%000100%
File 2: GetResult()0%00080%
File 2: OnCompleted(...)0%0000%
File 2: UnsafeOnCompleted(...)0%00066.67%
File 2: SourceOnCompleted(...)0%0000%
File 3: Yield()0%0000%
File 3: Yield(...)0%0000%
File 3: Yield(...)0%0000%
File 3: Yield(...)0%0000%
File 3: NextFrame()0%0000%
File 3: NextFrame(...)0%0000%
File 3: NextFrame(...)0%0000%
File 3: NextFrame(...)0%0000%
File 3: WaitForEndOfFrame()0%0000%
File 3: WaitForEndOfFrame(...)0%0000%
File 3: WaitForEndOfFrame(...)0%0000%
File 3: WaitForEndOfFrame(...)0%0000%
File 3: WaitForFixedUpdate()0%0000%
File 3: WaitForFixedUpdate(...)0%0000%
File 3: WaitForSeconds(...)0%0000%
File 3: WaitForSeconds(...)0%0000%
File 3: DelayFrame(...)0%0000%
File 3: Delay(...)0%0000%
File 3: Delay(...)0%000100%
File 3: Delay(...)0%0000%
File 3: Delay(...)0%00043.75%
File 3: YieldPromise()0%0000%
File 3: YieldPromise()0%0000%
File 3: Create(...)0%0000%
File 3: GetResult(...)0%0000%
File 3: GetStatus(...)0%0000%
File 3: UnsafeGetStatus()0%0000%
File 3: OnCompleted(...)0%0000%
File 3: MoveNext()0%0000%
File 3: TryReturn()0%0000%
File 3: NextFramePromise()0%0000%
File 3: NextFramePromise()0%0000%
File 3: Create(...)0%0000%
File 3: GetResult(...)0%0000%
File 3: GetStatus(...)0%0000%
File 3: UnsafeGetStatus()0%0000%
File 3: OnCompleted(...)0%0000%
File 3: MoveNext()0%0000%
File 3: TryReturn()0%0000%
File 3: Create(...)0%0000%
File 3: GetResult(...)0%0000%
File 3: GetStatus(...)0%0000%
File 3: UnsafeGetStatus()0%0000%
File 3: OnCompleted(...)0%0000%
File 3: TryReturn()0%0000%
File 3: WaitForEndOfFramePromise()0%0000%
File 3: WaitForEndOfFramePromise()0%0000%
File 3: get_Current()0%0000%
File 3: MoveNext()0%0000%
File 3: Reset()0%0000%
File 3: DelayFramePromise()0%0000%
File 3: DelayFramePromise()0%0000%
File 3: Create(...)0%0000%
File 3: GetResult(...)0%0000%
File 3: GetStatus(...)0%0000%
File 3: UnsafeGetStatus()0%0000%
File 3: OnCompleted(...)0%0000%
File 3: MoveNext()0%0000%
File 3: TryReturn()0%0000%
File 3: DelayPromise()0%000100%
File 3: DelayPromise()0%000100%
File 3: Create(...)0%00077.27%
File 3: GetResult(...)0%000100%
File 3: GetStatus(...)0%000100%
File 3: UnsafeGetStatus()0%0000%
File 3: OnCompleted(...)0%000100%
File 3: MoveNext()0%00083.33%
File 3: TryReturn()0%000100%
File 3: DelayIgnoreTimeScalePromise()0%0000%
File 3: DelayIgnoreTimeScalePromise()0%0000%
File 3: Create(...)0%0000%
File 3: GetResult(...)0%0000%
File 3: GetStatus(...)0%0000%
File 3: UnsafeGetStatus()0%0000%
File 3: OnCompleted(...)0%0000%
File 3: MoveNext()0%0000%
File 3: TryReturn()0%0000%
File 3: DelayRealtimePromise()0%0000%
File 3: DelayRealtimePromise()0%0000%
File 3: Create(...)0%0000%
File 3: GetResult(...)0%0000%
File 3: GetStatus(...)0%0000%
File 3: UnsafeGetStatus()0%0000%
File 3: OnCompleted(...)0%0000%
File 3: MoveNext()0%0000%
File 3: TryReturn()0%0000%
File 4: UniTask()0%0000%
File 4: FromException(...)0%0000%
File 4: FromException[T](...)0%0000%
File 4: FromResult[T](...)0%0000%
File 4: FromCanceled(...)0%0000%
File 4: FromCanceled[T](...)0%0000%
File 4: Create(...)0%0000%
File 4: Create[T](...)0%0000%
File 4: Lazy(...)0%0000%
File 4: Lazy[T](...)0%0000%
File 4: Void(...)0%0000%
File 4: Void(...)0%0000%
File 4: Void[T](...)0%0000%
File 4: Action(...)0%0000%
File 4: Action(...)0%0000%
File 4: UnityAction(...)0%0000%
File 4: UnityAction(...)0%0000%
File 4: Defer(...)0%0000%
File 4: Defer[T](...)0%0000%
File 4: Never(...)0%0000%
File 4: Never[T](...)0%0000%
File 4: ExceptionResultSource(...)0%0000%
File 4: GetResult(...)0%0000%
File 4: GetStatus(...)0%0000%
File 4: UnsafeGetStatus()0%0000%
File 4: OnCompleted(...)0%0000%
File 4: Finalize()0%0000%
File 4: CanceledResultSource(...)0%0000%
File 4: GetResult(...)0%0000%
File 4: GetStatus(...)0%0000%
File 4: UnsafeGetStatus()0%0000%
File 4: OnCompleted(...)0%0000%
File 4: DeferPromise(...)0%0000%
File 4: GetResult(...)0%0000%
File 4: GetStatus(...)0%0000%
File 4: OnCompleted(...)0%0000%
File 4: UnsafeGetStatus()0%0000%
File 5: Run(...)0%0000%
File 5: Run(...)0%0000%
File 5: Run(...)0%0000%
File 5: Run(...)0%0000%
File 5: Run[T](...)0%0000%
File 5: Run[T](...)0%0000%
File 5: Run[T](...)0%0000%
File 5: Run[T](...)0%0000%
File 5: RunOnThreadPool()0%0000%
File 5: RunOnThreadPool()0%0000%
File 5: RunOnThreadPool()0%0000%
File 5: RunOnThreadPool()0%0000%
File 6: SwitchToMainThread(...)0%0000%
File 6: SwitchToMainThread(...)0%0000%
File 6: ReturnToMainThread(...)0%0000%
File 6: ReturnToMainThread(...)0%0000%
File 6: Post(...)0%0000%
File 6: SwitchToThreadPool()0%0000%
File 6: SwitchToTaskPool()0%0000%
File 6: SwitchToSynchronizationContext(...)0%0000%
File 6: ReturnToSynchronizationContext(...)0%0000%
File 6: ReturnToCurrentSynchronizationContext(...)0%0000%
File 7: WaitUntil(...)0%0000%
File 7: WaitWhile(...)0%0000%
File 7: WaitUntilCanceled(...)0%0000%
File 7: WaitUntilValueChanged[T, U](...)0%0000%
File 7: WaitUntilPromise()0%0000%
File 7: WaitUntilPromise()0%0000%
File 7: Create(...)0%0000%
File 7: GetResult(...)0%0000%
File 7: GetStatus(...)0%0000%
File 7: UnsafeGetStatus()0%0000%
File 7: OnCompleted(...)0%0000%
File 7: MoveNext()0%0000%
File 7: TryReturn()0%0000%
File 7: WaitWhilePromise()0%0000%
File 7: WaitWhilePromise()0%0000%
File 7: Create(...)0%0000%
File 7: GetResult(...)0%0000%
File 7: GetStatus(...)0%0000%
File 7: UnsafeGetStatus()0%0000%
File 7: OnCompleted(...)0%0000%
File 7: MoveNext()0%0000%
File 7: TryReturn()0%0000%
File 7: WaitUntilCanceledPromise()0%0000%
File 7: WaitUntilCanceledPromise()0%0000%
File 7: Create(...)0%0000%
File 7: GetResult(...)0%0000%
File 7: GetStatus(...)0%0000%
File 7: UnsafeGetStatus()0%0000%
File 7: OnCompleted(...)0%0000%
File 7: MoveNext()0%0000%
File 7: TryReturn()0%0000%
File 8: WhenAll[T]()0%0000%
File 8: WhenAll[T](...)0%0000%
File 8: WhenAll(...)0%0000%
File 8: WhenAll(...)0%0000%
File 8: WhenAllPromise(...)0%0000%
File 8: TryInvokeContinuation(...)0%0000%
File 8: GetResult(...)0%0000%
File 8: GetStatus(...)0%0000%
File 8: UnsafeGetStatus()0%0000%
File 8: OnCompleted(...)0%0000%
File 9: WhenAll[T1, T2](...)0%0000%
File 9: WhenAll[T1, T2, T3](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](...)0%0000%
File 9: WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](...)0%0000%
File 10: WhenAny[T](...)0%0000%
File 10: WhenAny[T]()0%0000%
File 10: WhenAny[T](...)0%0000%
File 10: WhenAny(...)0%0000%
File 10: WhenAny(...)0%0000%
File 10: WhenAnyPromise(...)0%0000%
File 10: TryInvokeContinuation(...)0%0000%
File 10: GetResult(...)0%0000%
File 10: GetStatus(...)0%0000%
File 10: OnCompleted(...)0%0000%
File 10: UnsafeGetStatus()0%0000%
File 10: GetResult(...)0%0000%
File 11: WhenAny[T1, T2](...)0%0000%
File 11: WhenAny[T1, T2, T3](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](...)0%0000%
File 11: WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](...)0%0000%

File(s)

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Bridge.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using System;
 4using System.Collections;
 5
 6namespace Cysharp.Threading.Tasks
 7{
 8    // UnityEngine Bridges.
 9
 10    public partial struct UniTask
 11    {
 12        public static IEnumerator ToCoroutine(Func<UniTask> taskFactory)
 013        {
 014            return taskFactory().ToCoroutine();
 015        }
 16    }
 17}
 18

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2#pragma warning disable CS0436
 3
 4#if UNITASK_NETCORE || UNITY_2022_3_OR_NEWER
 5#define SUPPORT_VALUETASK
 6#endif
 7
 8using Cysharp.Threading.Tasks.CompilerServices;
 9using System;
 10using System.Diagnostics;
 11using System.Runtime.CompilerServices;
 12using System.Runtime.ExceptionServices;
 13using System.Runtime.InteropServices;
 14
 15namespace Cysharp.Threading.Tasks
 16{
 17    internal static class AwaiterActions
 18    {
 19        internal static readonly Action<object> InvokeContinuationDelegate = Continuation;
 20
 21        [DebuggerHidden]
 22        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 23        static void Continuation(object state)
 24        {
 25            ((Action)state).Invoke();
 26        }
 27    }
 28
 29    /// <summary>
 30    /// Lightweight unity specified task-like object.
 31    /// </summary>
 32    [AsyncMethodBuilder(typeof(AsyncUniTaskMethodBuilder))]
 33    [StructLayout(LayoutKind.Auto)]
 34    public readonly partial struct UniTask
 35    {
 36        readonly IUniTaskSource source;
 37        readonly short token;
 38
 39        [DebuggerHidden]
 40        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 41        public UniTask(IUniTaskSource source, short token)
 30342        {
 30343            this.source = source;
 30344            this.token = token;
 30345        }
 46
 47        public UniTaskStatus Status
 48        {
 49            [DebuggerHidden]
 50            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 51            get
 30352            {
 30353                if (source == null) return UniTaskStatus.Succeeded;
 30354                return source.GetStatus(token);
 30355            }
 56        }
 57
 58        [DebuggerHidden]
 59        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 60        public Awaiter GetAwaiter()
 30361        {
 30362            return new Awaiter(this);
 30363        }
 64
 65        /// <summary>
 66        /// returns (bool IsCanceled) instead of throws OperationCanceledException.
 67        /// </summary>
 68        public UniTask<bool> SuppressCancellationThrow()
 069        {
 070            var status = Status;
 071            if (status == UniTaskStatus.Succeeded) return CompletedTasks.False;
 072            if (status == UniTaskStatus.Canceled) return CompletedTasks.True;
 073            return new UniTask<bool>(new IsCanceledSource(source), token);
 074        }
 75
 76#if SUPPORT_VALUETASK
 77
 78        public static implicit operator System.Threading.Tasks.ValueTask(in UniTask self)
 079        {
 080            if (self.source == null)
 081            {
 082                return default;
 83            }
 84
 85#if (UNITASK_NETCORE && NETSTANDARD2_0)
 86            return self.AsValueTask();
 87#else
 088            return new System.Threading.Tasks.ValueTask(self.source, self.token);
 89#endif
 090        }
 91
 92#endif
 93
 94        public override string ToString()
 095        {
 096            if (source == null) return "()";
 097            return "(" + source.UnsafeGetStatus() + ")";
 098        }
 99
 100        /// <summary>
 101        /// Memoizing inner IValueTaskSource. The result UniTask can await multiple.
 102        /// </summary>
 103        public UniTask Preserve()
 0104        {
 0105            if (source == null)
 0106            {
 0107                return this;
 108            }
 109            else
 0110            {
 0111                return new UniTask(new MemoizeSource(source), token);
 112            }
 0113        }
 114
 115        public UniTask<AsyncUnit> AsAsyncUnitUniTask()
 0116        {
 0117            if (this.source == null) return CompletedTasks.AsyncUnit;
 118
 0119            var status = this.source.GetStatus(this.token);
 0120            if (status.IsCompletedSuccessfully())
 0121            {
 0122                this.source.GetResult(this.token);
 0123                return CompletedTasks.AsyncUnit;
 124            }
 0125            else if (this.source is IUniTaskSource<AsyncUnit> asyncUnitSource)
 0126            {
 0127                return new UniTask<AsyncUnit>(asyncUnitSource, this.token);
 128            }
 129
 0130            return new UniTask<AsyncUnit>(new AsyncUnitSource(this.source), this.token);
 0131        }
 132
 133        sealed class AsyncUnitSource : IUniTaskSource<AsyncUnit>
 134        {
 135            readonly IUniTaskSource source;
 136
 0137            public AsyncUnitSource(IUniTaskSource source)
 0138            {
 0139                this.source = source;
 0140            }
 141
 142            public AsyncUnit GetResult(short token)
 0143            {
 0144                source.GetResult(token);
 0145                return AsyncUnit.Default;
 0146            }
 147
 148            public UniTaskStatus GetStatus(short token)
 0149            {
 0150                return source.GetStatus(token);
 0151            }
 152
 153            public void OnCompleted(Action<object> continuation, object state, short token)
 0154            {
 0155                source.OnCompleted(continuation, state, token);
 0156            }
 157
 158            public UniTaskStatus UnsafeGetStatus()
 0159            {
 0160                return source.UnsafeGetStatus();
 0161            }
 162
 163            void IUniTaskSource.GetResult(short token)
 0164            {
 0165                GetResult(token);
 0166            }
 167        }
 168
 169        sealed class IsCanceledSource : IUniTaskSource<bool>
 170        {
 171            readonly IUniTaskSource source;
 172
 0173            public IsCanceledSource(IUniTaskSource source)
 0174            {
 0175                this.source = source;
 0176            }
 177
 178            public bool GetResult(short token)
 0179            {
 0180                if (source.GetStatus(token) == UniTaskStatus.Canceled)
 0181                {
 0182                    return true;
 183                }
 184
 0185                source.GetResult(token);
 0186                return false;
 0187            }
 188
 189            void IUniTaskSource.GetResult(short token)
 0190            {
 0191                GetResult(token);
 0192            }
 193
 194            public UniTaskStatus GetStatus(short token)
 0195            {
 0196                return source.GetStatus(token);
 0197            }
 198
 199            public UniTaskStatus UnsafeGetStatus()
 0200            {
 0201                return source.UnsafeGetStatus();
 0202            }
 203
 204            public void OnCompleted(Action<object> continuation, object state, short token)
 0205            {
 0206                source.OnCompleted(continuation, state, token);
 0207            }
 208        }
 209
 210        sealed class MemoizeSource : IUniTaskSource
 211        {
 212            IUniTaskSource source;
 213            ExceptionDispatchInfo exception;
 214            UniTaskStatus status;
 215
 0216            public MemoizeSource(IUniTaskSource source)
 0217            {
 0218                this.source = source;
 0219            }
 220
 221            public void GetResult(short token)
 0222            {
 0223                if (source == null)
 0224                {
 0225                    if (exception != null)
 0226                    {
 0227                        exception.Throw();
 0228                    }
 0229                }
 230                else
 0231                {
 232                    try
 0233                    {
 0234                        source.GetResult(token);
 0235                        status = UniTaskStatus.Succeeded;
 0236                    }
 0237                    catch (Exception ex)
 0238                    {
 0239                        exception = ExceptionDispatchInfo.Capture(ex);
 0240                        if (ex is OperationCanceledException)
 0241                        {
 0242                            status = UniTaskStatus.Canceled;
 0243                        }
 244                        else
 0245                        {
 0246                            status = UniTaskStatus.Faulted;
 0247                        }
 0248                        throw;
 249                    }
 250                    finally
 0251                    {
 0252                        source = null;
 0253                    }
 0254                }
 0255            }
 256
 257            public UniTaskStatus GetStatus(short token)
 0258            {
 0259                if (source == null)
 0260                {
 0261                    return status;
 262                }
 263
 0264                return source.GetStatus(token);
 0265            }
 266
 267            public void OnCompleted(Action<object> continuation, object state, short token)
 0268            {
 0269                if (source == null)
 0270                {
 0271                    continuation(state);
 0272                }
 273                else
 0274                {
 0275                    source.OnCompleted(continuation, state, token);
 0276                }
 0277            }
 278
 279            public UniTaskStatus UnsafeGetStatus()
 0280            {
 0281                if (source == null)
 0282                {
 0283                    return status;
 284                }
 285
 0286                return source.UnsafeGetStatus();
 0287            }
 288        }
 289
 290        public readonly struct Awaiter : ICriticalNotifyCompletion
 291        {
 292            readonly UniTask task;
 293
 294            [DebuggerHidden]
 295            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 296            public Awaiter(in UniTask task)
 303297            {
 303298                this.task = task;
 303299            }
 300
 301            public bool IsCompleted
 302            {
 303                [DebuggerHidden]
 304                [MethodImpl(MethodImplOptions.AggressiveInlining)]
 305                get
 303306                {
 303307                    return task.Status.IsCompleted();
 303308                }
 309            }
 310
 311            [DebuggerHidden]
 312            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 313            public void GetResult()
 303314            {
 303315                if (task.source == null) return;
 303316                task.source.GetResult(task.token);
 303317            }
 318
 319            [DebuggerHidden]
 320            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 321            public void OnCompleted(Action continuation)
 0322            {
 0323                if (task.source == null)
 0324                {
 0325                    continuation();
 0326                }
 327                else
 0328                {
 0329                    task.source.OnCompleted(AwaiterActions.InvokeContinuationDelegate, continuation, task.token);
 0330                }
 0331            }
 332
 333            [DebuggerHidden]
 334            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 335            public void UnsafeOnCompleted(Action continuation)
 303336            {
 303337                if (task.source == null)
 0338                {
 0339                    continuation();
 0340                }
 341                else
 303342                {
 303343                    task.source.OnCompleted(AwaiterActions.InvokeContinuationDelegate, continuation, task.token);
 303344                }
 303345            }
 346
 347            /// <summary>
 348            /// If register manually continuation, you can use it instead of for compiler OnCompleted methods.
 349            /// </summary>
 350            [DebuggerHidden]
 351            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 352            public void SourceOnCompleted(Action<object> continuation, object state)
 0353            {
 0354                if (task.source == null)
 0355                {
 0356                    continuation(state);
 0357                }
 358                else
 0359                {
 0360                    task.source.OnCompleted(continuation, state, task.token);
 0361                }
 0362            }
 363        }
 364    }
 365
 366    /// <summary>
 367    /// Lightweight unity specified task-like object.
 368    /// </summary>
 369    [AsyncMethodBuilder(typeof(AsyncUniTaskMethodBuilder<>))]
 370    [StructLayout(LayoutKind.Auto)]
 371    public readonly struct UniTask<T>
 372    {
 373        readonly IUniTaskSource<T> source;
 374        readonly T result;
 375        readonly short token;
 376
 377        [DebuggerHidden]
 378        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 379        public UniTask(T result)
 380        {
 381            this.source = default;
 382            this.token = default;
 383            this.result = result;
 384        }
 385
 386        [DebuggerHidden]
 387        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 388        public UniTask(IUniTaskSource<T> source, short token)
 389        {
 390            this.source = source;
 391            this.token = token;
 392            this.result = default;
 393        }
 394
 395        public UniTaskStatus Status
 396        {
 397            [DebuggerHidden]
 398            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 399            get
 400            {
 401                return (source == null) ? UniTaskStatus.Succeeded : source.GetStatus(token);
 402            }
 403        }
 404
 405        [DebuggerHidden]
 406        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 407        public Awaiter GetAwaiter()
 408        {
 409            return new Awaiter(this);
 410        }
 411
 412        /// <summary>
 413        /// Memoizing inner IValueTaskSource. The result UniTask can await multiple.
 414        /// </summary>
 415        public UniTask<T> Preserve()
 416        {
 417            if (source == null)
 418            {
 419                return this;
 420            }
 421            else
 422            {
 423                return new UniTask<T>(new MemoizeSource(source), token);
 424            }
 425        }
 426
 427        public UniTask AsUniTask()
 428        {
 429            if (this.source == null) return UniTask.CompletedTask;
 430
 431            var status = this.source.GetStatus(this.token);
 432            if (status.IsCompletedSuccessfully())
 433            {
 434                this.source.GetResult(this.token);
 435                return UniTask.CompletedTask;
 436            }
 437
 438            // Converting UniTask<T> -> UniTask is zero overhead.
 439            return new UniTask(this.source, this.token);
 440        }
 441
 442        public static implicit operator UniTask(UniTask<T> self)
 443        {
 444            return self.AsUniTask();
 445        }
 446
 447#if SUPPORT_VALUETASK
 448
 449        public static implicit operator System.Threading.Tasks.ValueTask<T>(in UniTask<T> self)
 450        {
 451            if (self.source == null)
 452            {
 453                return new System.Threading.Tasks.ValueTask<T>(self.result);
 454            }
 455
 456#if (UNITASK_NETCORE && NETSTANDARD2_0)
 457            return self.AsValueTask();
 458#else
 459            return new System.Threading.Tasks.ValueTask<T>(self.source, self.token);
 460#endif
 461        }
 462
 463#endif
 464
 465        /// <summary>
 466        /// returns (bool IsCanceled, T Result) instead of throws OperationCanceledException.
 467        /// </summary>
 468        public UniTask<(bool IsCanceled, T Result)> SuppressCancellationThrow()
 469        {
 470            if (source == null)
 471            {
 472                return new UniTask<(bool IsCanceled, T Result)>((false, result));
 473            }
 474
 475            return new UniTask<(bool, T)>(new IsCanceledSource(source), token);
 476        }
 477
 478        public override string ToString()
 479        {
 480            return (this.source == null) ? result?.ToString()
 481                 : "(" + this.source.UnsafeGetStatus() + ")";
 482        }
 483
 484        sealed class IsCanceledSource : IUniTaskSource<(bool, T)>
 485        {
 486            readonly IUniTaskSource<T> source;
 487
 488            [DebuggerHidden]
 489            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 490            public IsCanceledSource(IUniTaskSource<T> source)
 491            {
 492                this.source = source;
 493            }
 494
 495            [DebuggerHidden]
 496            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 497            public (bool, T) GetResult(short token)
 498            {
 499                if (source.GetStatus(token) == UniTaskStatus.Canceled)
 500                {
 501                    return (true, default);
 502                }
 503
 504                var result = source.GetResult(token);
 505                return (false, result);
 506            }
 507
 508            [DebuggerHidden]
 509            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 510            void IUniTaskSource.GetResult(short token)
 511            {
 512                GetResult(token);
 513            }
 514
 515            [DebuggerHidden]
 516            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 517            public UniTaskStatus GetStatus(short token)
 518            {
 519                return source.GetStatus(token);
 520            }
 521
 522            [DebuggerHidden]
 523            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 524            public UniTaskStatus UnsafeGetStatus()
 525            {
 526                return source.UnsafeGetStatus();
 527            }
 528
 529            [DebuggerHidden]
 530            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 531            public void OnCompleted(Action<object> continuation, object state, short token)
 532            {
 533                source.OnCompleted(continuation, state, token);
 534            }
 535        }
 536
 537        sealed class MemoizeSource : IUniTaskSource<T>
 538        {
 539            IUniTaskSource<T> source;
 540            T result;
 541            ExceptionDispatchInfo exception;
 542            UniTaskStatus status;
 543
 544            public MemoizeSource(IUniTaskSource<T> source)
 545            {
 546                this.source = source;
 547            }
 548
 549            public T GetResult(short token)
 550            {
 551                if (source == null)
 552                {
 553                    if (exception != null)
 554                    {
 555                        exception.Throw();
 556                    }
 557                    return result;
 558                }
 559                else
 560                {
 561                    try
 562                    {
 563                        result = source.GetResult(token);
 564                        status = UniTaskStatus.Succeeded;
 565                        return result;
 566                    }
 567                    catch (Exception ex)
 568                    {
 569                        exception = ExceptionDispatchInfo.Capture(ex);
 570                        if (ex is OperationCanceledException)
 571                        {
 572                            status = UniTaskStatus.Canceled;
 573                        }
 574                        else
 575                        {
 576                            status = UniTaskStatus.Faulted;
 577                        }
 578                        throw;
 579                    }
 580                    finally
 581                    {
 582                        source = null;
 583                    }
 584                }
 585            }
 586
 587            void IUniTaskSource.GetResult(short token)
 588            {
 589                GetResult(token);
 590            }
 591
 592            public UniTaskStatus GetStatus(short token)
 593            {
 594                if (source == null)
 595                {
 596                    return status;
 597                }
 598
 599                return source.GetStatus(token);
 600            }
 601
 602            public void OnCompleted(Action<object> continuation, object state, short token)
 603            {
 604                if (source == null)
 605                {
 606                    continuation(state);
 607                }
 608                else
 609                {
 610                    source.OnCompleted(continuation, state, token);
 611                }
 612            }
 613
 614            public UniTaskStatus UnsafeGetStatus()
 615            {
 616                if (source == null)
 617                {
 618                    return status;
 619                }
 620
 621                return source.UnsafeGetStatus();
 622            }
 623        }
 624
 625        public readonly struct Awaiter : ICriticalNotifyCompletion
 626        {
 627            readonly UniTask<T> task;
 628
 629            [DebuggerHidden]
 630            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 631            public Awaiter(in UniTask<T> task)
 632            {
 633                this.task = task;
 634            }
 635
 636            public bool IsCompleted
 637            {
 638                [DebuggerHidden]
 639                [MethodImpl(MethodImplOptions.AggressiveInlining)]
 640                get
 641                {
 642                    return task.Status.IsCompleted();
 643                }
 644            }
 645
 646            [DebuggerHidden]
 647            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 648            public T GetResult()
 649            {
 650                var s = task.source;
 651                if (s == null)
 652                {
 653                    return task.result;
 654                }
 655                else
 656                {
 657                    return s.GetResult(task.token);
 658                }
 659            }
 660
 661            [DebuggerHidden]
 662            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 663            public void OnCompleted(Action continuation)
 664            {
 665                var s = task.source;
 666                if (s == null)
 667                {
 668                    continuation();
 669                }
 670                else
 671                {
 672                    s.OnCompleted(AwaiterActions.InvokeContinuationDelegate, continuation, task.token);
 673                }
 674            }
 675
 676            [DebuggerHidden]
 677            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 678            public void UnsafeOnCompleted(Action continuation)
 679            {
 680                var s = task.source;
 681                if (s == null)
 682                {
 683                    continuation();
 684                }
 685                else
 686                {
 687                    s.OnCompleted(AwaiterActions.InvokeContinuationDelegate, continuation, task.token);
 688                }
 689            }
 690
 691            /// <summary>
 692            /// If register manually continuation, you can use it instead of for compiler OnCompleted methods.
 693            /// </summary>
 694            [DebuggerHidden]
 695            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 696            public void SourceOnCompleted(Action<object> continuation, object state)
 697            {
 698                var s = task.source;
 699                if (s == null)
 700                {
 701                    continuation(state);
 702                }
 703                else
 704                {
 705                    s.OnCompleted(continuation, state, task.token);
 706                }
 707            }
 708        }
 709    }
 710}
 711

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using Cysharp.Threading.Tasks.Internal;
 4using System;
 5using System.Collections;
 6using System.Runtime.CompilerServices;
 7using System.Threading;
 8using UnityEngine;
 9
 10namespace Cysharp.Threading.Tasks
 11{
 12    public enum DelayType
 13    {
 14        /// <summary>use Time.deltaTime.</summary>
 15        DeltaTime,
 16        /// <summary>Ignore timescale, use Time.unscaledDeltaTime.</summary>
 17        UnscaledDeltaTime,
 18        /// <summary>use Stopwatch.GetTimestamp().</summary>
 19        Realtime
 20    }
 21
 22    public partial struct UniTask
 23    {
 24        public static YieldAwaitable Yield()
 025        {
 26            // optimized for single continuation
 027            return new YieldAwaitable(PlayerLoopTiming.Update);
 028        }
 29
 30        public static YieldAwaitable Yield(PlayerLoopTiming timing)
 031        {
 32            // optimized for single continuation
 033            return new YieldAwaitable(timing);
 034        }
 35
 36        public static UniTask Yield(CancellationToken cancellationToken, bool cancelImmediately = false)
 037        {
 038            return new UniTask(YieldPromise.Create(PlayerLoopTiming.Update, cancellationToken, cancelImmediately, out va
 039        }
 40
 41        public static UniTask Yield(PlayerLoopTiming timing, CancellationToken cancellationToken, bool cancelImmediately
 042        {
 043            return new UniTask(YieldPromise.Create(timing, cancellationToken, cancelImmediately, out var token), token);
 044        }
 45
 46        /// <summary>
 47        /// Similar as UniTask.Yield but guaranteed run on next frame.
 48        /// </summary>
 49        public static UniTask NextFrame()
 050        {
 051            return new UniTask(NextFramePromise.Create(PlayerLoopTiming.Update, CancellationToken.None, false, out var t
 052        }
 53
 54        /// <summary>
 55        /// Similar as UniTask.Yield but guaranteed run on next frame.
 56        /// </summary>
 57        public static UniTask NextFrame(PlayerLoopTiming timing)
 058        {
 059            return new UniTask(NextFramePromise.Create(timing, CancellationToken.None, false, out var token), token);
 060        }
 61
 62        /// <summary>
 63        /// Similar as UniTask.Yield but guaranteed run on next frame.
 64        /// </summary>
 65        public static UniTask NextFrame(CancellationToken cancellationToken, bool cancelImmediately = false)
 066        {
 067            return new UniTask(NextFramePromise.Create(PlayerLoopTiming.Update, cancellationToken, cancelImmediately, ou
 068        }
 69
 70        /// <summary>
 71        /// Similar as UniTask.Yield but guaranteed run on next frame.
 72        /// </summary>
 73        public static UniTask NextFrame(PlayerLoopTiming timing, CancellationToken cancellationToken, bool cancelImmedia
 074        {
 075            return new UniTask(NextFramePromise.Create(timing, cancellationToken, cancelImmediately, out var token), tok
 076        }
 77
 78#if UNITY_2023_1_OR_NEWER
 79        public static async UniTask WaitForEndOfFrame(CancellationToken cancellationToken = default)
 80        {
 81            await Awaitable.EndOfFrameAsync(cancellationToken);
 82        }
 83#else
 84        [Obsolete("Use WaitForEndOfFrame(MonoBehaviour) instead or UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate). E
 85        public static YieldAwaitable WaitForEndOfFrame()
 086        {
 087            return UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate);
 088        }
 89
 90        [Obsolete("Use WaitForEndOfFrame(MonoBehaviour) instead or UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate). E
 91        public static UniTask WaitForEndOfFrame(CancellationToken cancellationToken, bool cancelImmediately = false)
 092        {
 093            return UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate, cancellationToken, cancelImmediately);
 094        }
 95#endif
 96
 97        public static UniTask WaitForEndOfFrame(MonoBehaviour coroutineRunner)
 098        {
 099            var source = WaitForEndOfFramePromise.Create(coroutineRunner, CancellationToken.None, false, out var token);
 0100            return new UniTask(source, token);
 0101        }
 102
 103        public static UniTask WaitForEndOfFrame(MonoBehaviour coroutineRunner, CancellationToken cancellationToken, bool
 0104        {
 0105            var source = WaitForEndOfFramePromise.Create(coroutineRunner, cancellationToken, cancelImmediately, out var 
 0106            return new UniTask(source, token);
 0107        }
 108
 109        /// <summary>
 110        /// Same as UniTask.Yield(PlayerLoopTiming.LastFixedUpdate).
 111        /// </summary>
 112        public static YieldAwaitable WaitForFixedUpdate()
 0113        {
 114            // use LastFixedUpdate instead of FixedUpdate
 115            // https://github.com/Cysharp/UniTask/issues/377
 0116            return UniTask.Yield(PlayerLoopTiming.LastFixedUpdate);
 0117        }
 118
 119        /// <summary>
 120        /// Same as UniTask.Yield(PlayerLoopTiming.LastFixedUpdate, cancellationToken).
 121        /// </summary>
 122        public static UniTask WaitForFixedUpdate(CancellationToken cancellationToken, bool cancelImmediately = false)
 0123        {
 0124            return UniTask.Yield(PlayerLoopTiming.LastFixedUpdate, cancellationToken, cancelImmediately);
 0125        }
 126
 127    public static UniTask WaitForSeconds(float duration, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = Pl
 0128    {
 0129      return Delay(Mathf.RoundToInt(1000 * duration), ignoreTimeScale, delayTiming, cancellationToken, cancelImmediately
 0130    }
 131
 132    public static UniTask WaitForSeconds(int duration, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = Play
 0133    {
 0134      return Delay(1000 * duration, ignoreTimeScale, delayTiming, cancellationToken, cancelImmediately);
 0135    }
 136
 137    public static UniTask DelayFrame(int delayFrameCount, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update, Cancel
 0138        {
 0139            if (delayFrameCount < 0)
 0140            {
 0141                throw new ArgumentOutOfRangeException("Delay does not allow minus delayFrameCount. delayFrameCount:" + d
 142            }
 143
 0144            return new UniTask(DelayFramePromise.Create(delayFrameCount, delayTiming, cancellationToken, cancelImmediate
 0145        }
 146
 147        public static UniTask Delay(int millisecondsDelay, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = 
 0148        {
 0149            var delayTimeSpan = TimeSpan.FromMilliseconds(millisecondsDelay);
 0150            return Delay(delayTimeSpan, ignoreTimeScale, delayTiming, cancellationToken, cancelImmediately);
 0151        }
 152
 153        public static UniTask Delay(TimeSpan delayTimeSpan, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming =
 247154        {
 247155            var delayType = ignoreTimeScale ? DelayType.UnscaledDeltaTime : DelayType.DeltaTime;
 247156            return Delay(delayTimeSpan, delayType, delayTiming, cancellationToken, cancelImmediately);
 247157        }
 158
 159        public static UniTask Delay(int millisecondsDelay, DelayType delayType, PlayerLoopTiming delayTiming = PlayerLoo
 0160        {
 0161            var delayTimeSpan = TimeSpan.FromMilliseconds(millisecondsDelay);
 0162            return Delay(delayTimeSpan, delayType, delayTiming, cancellationToken, cancelImmediately);
 0163        }
 164
 165        public static UniTask Delay(TimeSpan delayTimeSpan, DelayType delayType, PlayerLoopTiming delayTiming = PlayerLo
 247166        {
 247167            if (delayTimeSpan < TimeSpan.Zero)
 0168            {
 0169                throw new ArgumentOutOfRangeException("Delay does not allow minus delayTimeSpan. delayTimeSpan:" + delay
 170            }
 171
 172#if UNITY_EDITOR
 173            // force use Realtime.
 247174            if (PlayerLoopHelper.IsMainThread && !UnityEditor.EditorApplication.isPlaying)
 0175            {
 0176                delayType = DelayType.Realtime;
 0177            }
 178#endif
 179
 247180            switch (delayType)
 181            {
 182                case DelayType.UnscaledDeltaTime:
 0183                    {
 0184                        return new UniTask(DelayIgnoreTimeScalePromise.Create(delayTimeSpan, delayTiming, cancellationTo
 185                    }
 186                case DelayType.Realtime:
 0187                    {
 0188                        return new UniTask(DelayRealtimePromise.Create(delayTimeSpan, delayTiming, cancellationToken, ca
 189                    }
 190                case DelayType.DeltaTime:
 191                default:
 247192                    {
 247193                        return new UniTask(DelayPromise.Create(delayTimeSpan, delayTiming, cancellationToken, cancelImme
 194                    }
 195            }
 247196        }
 197
 198        sealed class YieldPromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<YieldPromise>
 199        {
 200            static TaskPool<YieldPromise> pool;
 201            YieldPromise nextNode;
 0202            public ref YieldPromise NextNode => ref nextNode;
 203
 204            static YieldPromise()
 0205            {
 0206                TaskPool.RegisterSizeGetter(typeof(YieldPromise), () => pool.Size);
 0207            }
 208
 209            CancellationToken cancellationToken;
 210            CancellationTokenRegistration cancellationTokenRegistration;
 211            bool cancelImmediately;
 212            UniTaskCompletionSourceCore<object> core;
 213
 0214            YieldPromise()
 0215            {
 0216            }
 217
 218            public static IUniTaskSource Create(PlayerLoopTiming timing, CancellationToken cancellationToken, bool cance
 0219            {
 0220                if (cancellationToken.IsCancellationRequested)
 0221                {
 0222                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 223                }
 224
 0225                if (!pool.TryPop(out var result))
 0226                {
 0227                    result = new YieldPromise();
 0228                }
 229
 0230                result.cancellationToken = cancellationToken;
 0231                result.cancelImmediately = cancelImmediately;
 232
 0233                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0234                {
 0235                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0236                    {
 0237                        var promise = (YieldPromise)state;
 0238                        promise.core.TrySetCanceled(promise.cancellationToken);
 0239                    }, result);
 0240                }
 241
 0242                TaskTracker.TrackActiveTask(result, 3);
 243
 0244                PlayerLoopHelper.AddAction(timing, result);
 245
 0246                token = result.core.Version;
 0247                return result;
 0248            }
 249
 250            public void GetResult(short token)
 0251            {
 252                try
 0253                {
 0254                    core.GetResult(token);
 0255                }
 256                finally
 0257                {
 0258                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0259                    {
 0260                        TryReturn();
 0261                    }
 0262                }
 0263            }
 264
 265            public UniTaskStatus GetStatus(short token)
 0266            {
 0267                return core.GetStatus(token);
 0268            }
 269
 270            public UniTaskStatus UnsafeGetStatus()
 0271            {
 0272                return core.UnsafeGetStatus();
 0273            }
 274
 275            public void OnCompleted(Action<object> continuation, object state, short token)
 0276            {
 0277                core.OnCompleted(continuation, state, token);
 0278            }
 279
 280            public bool MoveNext()
 0281            {
 0282                if (cancellationToken.IsCancellationRequested)
 0283                {
 0284                    core.TrySetCanceled(cancellationToken);
 0285                    return false;
 286                }
 287
 0288                core.TrySetResult(null);
 0289                return false;
 0290            }
 291
 292            bool TryReturn()
 0293            {
 0294                TaskTracker.RemoveTracking(this);
 0295                core.Reset();
 0296                cancellationToken = default;
 0297                cancellationTokenRegistration.Dispose();
 0298                cancelImmediately = default;
 0299                return pool.TryPush(this);
 0300            }
 301        }
 302
 303        sealed class NextFramePromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<NextFramePromise>
 304        {
 305            static TaskPool<NextFramePromise> pool;
 306            NextFramePromise nextNode;
 0307            public ref NextFramePromise NextNode => ref nextNode;
 308
 309            static NextFramePromise()
 0310            {
 0311                TaskPool.RegisterSizeGetter(typeof(NextFramePromise), () => pool.Size);
 0312            }
 313
 314            int frameCount;
 315            UniTaskCompletionSourceCore<AsyncUnit> core;
 316            CancellationToken cancellationToken;
 317            CancellationTokenRegistration cancellationTokenRegistration;
 318            bool cancelImmediately;
 319
 0320            NextFramePromise()
 0321            {
 0322            }
 323
 324            public static IUniTaskSource Create(PlayerLoopTiming timing, CancellationToken cancellationToken, bool cance
 0325            {
 0326                if (cancellationToken.IsCancellationRequested)
 0327                {
 0328                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 329                }
 330
 0331                if (!pool.TryPop(out var result))
 0332                {
 0333                    result = new NextFramePromise();
 0334                }
 335
 0336                result.frameCount = PlayerLoopHelper.IsMainThread ? Time.frameCount : -1;
 0337                result.cancellationToken = cancellationToken;
 0338                result.cancelImmediately = cancelImmediately;
 339
 0340                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0341                {
 0342                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0343                    {
 0344                        var promise = (NextFramePromise)state;
 0345                        promise.core.TrySetCanceled(promise.cancellationToken);
 0346                    }, result);
 0347                }
 348
 0349                TaskTracker.TrackActiveTask(result, 3);
 350
 0351                PlayerLoopHelper.AddAction(timing, result);
 352
 0353                token = result.core.Version;
 0354                return result;
 0355            }
 356
 357            public void GetResult(short token)
 0358            {
 359                try
 0360                {
 0361                    core.GetResult(token);
 0362                }
 363                finally
 0364                {
 0365                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0366                    {
 0367                        TryReturn();
 0368                    }
 0369                }
 0370            }
 371
 372            public UniTaskStatus GetStatus(short token)
 0373            {
 0374                return core.GetStatus(token);
 0375            }
 376
 377            public UniTaskStatus UnsafeGetStatus()
 0378            {
 0379                return core.UnsafeGetStatus();
 0380            }
 381
 382            public void OnCompleted(Action<object> continuation, object state, short token)
 0383            {
 0384                core.OnCompleted(continuation, state, token);
 0385            }
 386
 387            public bool MoveNext()
 0388            {
 0389                if (cancellationToken.IsCancellationRequested)
 0390                {
 0391                    core.TrySetCanceled(cancellationToken);
 0392                    return false;
 393                }
 394
 0395                if (frameCount == Time.frameCount)
 0396                {
 0397                    return true;
 398                }
 399
 0400                core.TrySetResult(AsyncUnit.Default);
 0401                return false;
 0402            }
 403
 404            bool TryReturn()
 0405            {
 0406                TaskTracker.RemoveTracking(this);
 0407                core.Reset();
 0408                cancellationToken = default;
 0409                cancellationTokenRegistration.Dispose();
 0410                return pool.TryPush(this);
 0411            }
 412        }
 413
 414        sealed class WaitForEndOfFramePromise : IUniTaskSource, ITaskPoolNode<WaitForEndOfFramePromise>, System.Collecti
 415        {
 416            static TaskPool<WaitForEndOfFramePromise> pool;
 417            WaitForEndOfFramePromise nextNode;
 0418            public ref WaitForEndOfFramePromise NextNode => ref nextNode;
 419
 420            static WaitForEndOfFramePromise()
 0421            {
 0422                TaskPool.RegisterSizeGetter(typeof(WaitForEndOfFramePromise), () => pool.Size);
 0423            }
 424
 425            UniTaskCompletionSourceCore<object> core;
 426            CancellationToken cancellationToken;
 427            CancellationTokenRegistration cancellationTokenRegistration;
 428            bool cancelImmediately;
 429
 0430            WaitForEndOfFramePromise()
 0431            {
 0432            }
 433
 434            public static IUniTaskSource Create(MonoBehaviour coroutineRunner, CancellationToken cancellationToken, bool
 0435            {
 0436                if (cancellationToken.IsCancellationRequested)
 0437                {
 0438                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 439                }
 440
 0441                if (!pool.TryPop(out var result))
 0442                {
 0443                    result = new WaitForEndOfFramePromise();
 0444                }
 445
 0446                result.cancellationToken = cancellationToken;
 0447                result.cancelImmediately = cancelImmediately;
 448
 0449                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0450                {
 0451                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0452                    {
 0453                        var promise = (WaitForEndOfFramePromise)state;
 0454                        promise.core.TrySetCanceled(promise.cancellationToken);
 0455                    }, result);
 0456                }
 457
 0458                TaskTracker.TrackActiveTask(result, 3);
 459
 0460                coroutineRunner.StartCoroutine(result);
 461
 0462                token = result.core.Version;
 0463                return result;
 0464            }
 465
 466            public void GetResult(short token)
 0467            {
 468                try
 0469                {
 0470                    core.GetResult(token);
 0471                }
 472                finally
 0473                {
 0474                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0475                    {
 0476                        TryReturn();
 0477                    }
 0478                }
 0479            }
 480
 481            public UniTaskStatus GetStatus(short token)
 0482            {
 0483                return core.GetStatus(token);
 0484            }
 485
 486            public UniTaskStatus UnsafeGetStatus()
 0487            {
 0488                return core.UnsafeGetStatus();
 0489            }
 490
 491            public void OnCompleted(Action<object> continuation, object state, short token)
 0492            {
 0493                core.OnCompleted(continuation, state, token);
 0494            }
 495
 496            bool TryReturn()
 0497            {
 0498                TaskTracker.RemoveTracking(this);
 0499                core.Reset();
 0500                Reset(); // Reset Enumerator
 0501                cancellationToken = default;
 0502                cancellationTokenRegistration.Dispose();
 0503                return pool.TryPush(this);
 0504            }
 505
 506            // Coroutine Runner implementation
 507
 0508            static readonly WaitForEndOfFrame waitForEndOfFrameYieldInstruction = new WaitForEndOfFrame();
 0509            bool isFirst = true;
 510
 0511            object IEnumerator.Current => waitForEndOfFrameYieldInstruction;
 512
 513            bool IEnumerator.MoveNext()
 0514            {
 0515                if (isFirst)
 0516                {
 0517                    isFirst = false;
 0518                    return true; // start WaitForEndOfFrame
 519                }
 520
 0521                if (cancellationToken.IsCancellationRequested)
 0522                {
 0523                    core.TrySetCanceled(cancellationToken);
 0524                    return false;
 525                }
 526
 0527                core.TrySetResult(null);
 0528                return false;
 0529            }
 530
 531            public void Reset()
 0532            {
 0533                isFirst = true;
 0534            }
 535        }
 536
 537        sealed class DelayFramePromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<DelayFramePromise>
 538        {
 539            static TaskPool<DelayFramePromise> pool;
 540            DelayFramePromise nextNode;
 0541            public ref DelayFramePromise NextNode => ref nextNode;
 542
 543            static DelayFramePromise()
 0544            {
 0545                TaskPool.RegisterSizeGetter(typeof(DelayFramePromise), () => pool.Size);
 0546            }
 547
 548            int initialFrame;
 549            int delayFrameCount;
 550            CancellationToken cancellationToken;
 551            CancellationTokenRegistration cancellationTokenRegistration;
 552            bool cancelImmediately;
 553
 554            int currentFrameCount;
 555            UniTaskCompletionSourceCore<AsyncUnit> core;
 556
 0557            DelayFramePromise()
 0558            {
 0559            }
 560
 561            public static IUniTaskSource Create(int delayFrameCount, PlayerLoopTiming timing, CancellationToken cancella
 0562            {
 0563                if (cancellationToken.IsCancellationRequested)
 0564                {
 0565                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 566                }
 567
 0568                if (!pool.TryPop(out var result))
 0569                {
 0570                    result = new DelayFramePromise();
 0571                }
 572
 0573                result.delayFrameCount = delayFrameCount;
 0574                result.cancellationToken = cancellationToken;
 0575                result.initialFrame = PlayerLoopHelper.IsMainThread ? Time.frameCount : -1;
 0576                result.cancelImmediately = cancelImmediately;
 577
 0578                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0579                {
 0580                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0581                    {
 0582                        var promise = (DelayFramePromise)state;
 0583                        promise.core.TrySetCanceled(promise.cancellationToken);
 0584                    }, result);
 0585                }
 586
 0587                TaskTracker.TrackActiveTask(result, 3);
 588
 0589                PlayerLoopHelper.AddAction(timing, result);
 590
 0591                token = result.core.Version;
 0592                return result;
 0593            }
 594
 595            public void GetResult(short token)
 0596            {
 597                try
 0598                {
 0599                    core.GetResult(token);
 0600                }
 601                finally
 0602                {
 0603                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0604                    {
 0605                        TryReturn();
 0606                    }
 0607                }
 0608            }
 609
 610            public UniTaskStatus GetStatus(short token)
 0611            {
 0612                return core.GetStatus(token);
 0613            }
 614
 615            public UniTaskStatus UnsafeGetStatus()
 0616            {
 0617                return core.UnsafeGetStatus();
 0618            }
 619
 620            public void OnCompleted(Action<object> continuation, object state, short token)
 0621            {
 0622                core.OnCompleted(continuation, state, token);
 0623            }
 624
 625            public bool MoveNext()
 0626            {
 0627                if (cancellationToken.IsCancellationRequested)
 0628                {
 0629                    core.TrySetCanceled(cancellationToken);
 0630                    return false;
 631                }
 632
 0633                if (currentFrameCount == 0)
 0634                {
 0635                    if (delayFrameCount == 0) // same as Yield
 0636                    {
 0637                        core.TrySetResult(AsyncUnit.Default);
 0638                        return false;
 639                    }
 640
 641                    // skip in initial frame.
 0642                    if (initialFrame == Time.frameCount)
 0643                    {
 644#if UNITY_EDITOR
 645                        // force use Realtime.
 0646                        if (PlayerLoopHelper.IsMainThread && !UnityEditor.EditorApplication.isPlaying)
 0647                        {
 648                            //goto ++currentFrameCount
 0649                        }
 650                        else
 0651                        {
 0652                            return true;
 653                        }
 654#else
 655                        return true;
 656#endif
 0657                    }
 0658                }
 659
 0660                if (++currentFrameCount >= delayFrameCount)
 0661                {
 0662                    core.TrySetResult(AsyncUnit.Default);
 0663                    return false;
 664                }
 665
 0666                return true;
 0667            }
 668
 669            bool TryReturn()
 0670            {
 0671                TaskTracker.RemoveTracking(this);
 0672                core.Reset();
 0673                currentFrameCount = default;
 0674                delayFrameCount = default;
 0675                cancellationToken = default;
 0676                cancellationTokenRegistration.Dispose();
 0677                cancelImmediately = default;
 0678                return pool.TryPush(this);
 0679            }
 680        }
 681
 682        sealed class DelayPromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<DelayPromise>
 683        {
 684            static TaskPool<DelayPromise> pool;
 685            DelayPromise nextNode;
 482686            public ref DelayPromise NextNode => ref nextNode;
 687
 688            static DelayPromise()
 1689            {
 1690                TaskPool.RegisterSizeGetter(typeof(DelayPromise), () => pool.Size);
 1691            }
 692
 693            int initialFrame;
 694            float delayTimeSpan;
 695            float elapsed;
 696            CancellationToken cancellationToken;
 697            CancellationTokenRegistration cancellationTokenRegistration;
 698            bool cancelImmediately;
 699
 700            UniTaskCompletionSourceCore<object> core;
 701
 12702            DelayPromise()
 12703            {
 12704            }
 705
 706            public static IUniTaskSource Create(TimeSpan delayTimeSpan, PlayerLoopTiming timing, CancellationToken cance
 247707            {
 247708                if (cancellationToken.IsCancellationRequested)
 0709                {
 0710                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 711                }
 712
 247713                if (!pool.TryPop(out var result))
 12714                {
 12715                    result = new DelayPromise();
 12716                }
 717
 247718                result.elapsed = 0.0f;
 247719                result.delayTimeSpan = (float)delayTimeSpan.TotalSeconds;
 247720                result.cancellationToken = cancellationToken;
 247721                result.initialFrame = PlayerLoopHelper.IsMainThread ? Time.frameCount : -1;
 247722                result.cancelImmediately = cancelImmediately;
 723
 247724                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0725                {
 0726                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0727                    {
 0728                        var promise = (DelayPromise)state;
 0729                        promise.core.TrySetCanceled(promise.cancellationToken);
 0730                    }, result);
 0731                }
 732
 247733                TaskTracker.TrackActiveTask(result, 3);
 734
 247735                PlayerLoopHelper.AddAction(timing, result);
 736
 247737                token = result.core.Version;
 247738                return result;
 247739            }
 740
 741            public void GetResult(short token)
 247742            {
 743                try
 247744                {
 247745                    core.GetResult(token);
 247746                }
 747                finally
 247748                {
 247749                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 247750                    {
 247751                        TryReturn();
 247752                    }
 247753                }
 247754            }
 755
 756            public UniTaskStatus GetStatus(short token)
 247757            {
 247758                return core.GetStatus(token);
 247759            }
 760
 761            public UniTaskStatus UnsafeGetStatus()
 0762            {
 0763                return core.UnsafeGetStatus();
 0764            }
 765
 766            public void OnCompleted(Action<object> continuation, object state, short token)
 247767            {
 247768                core.OnCompleted(continuation, state, token);
 247769            }
 770
 771            public bool MoveNext()
 7615772            {
 7615773                if (cancellationToken.IsCancellationRequested)
 0774                {
 0775                    core.TrySetCanceled(cancellationToken);
 0776                    return false;
 777                }
 778
 7615779                if (elapsed == 0.0f)
 261780                {
 261781                    if (initialFrame == Time.frameCount)
 14782                    {
 14783                        return true;
 784                    }
 247785                }
 786
 7601787                elapsed += Time.deltaTime;
 7601788                if (elapsed >= delayTimeSpan)
 247789                {
 247790                    core.TrySetResult(null);
 247791                    return false;
 792                }
 793
 7354794                return true;
 7615795            }
 796
 797            bool TryReturn()
 247798            {
 247799                TaskTracker.RemoveTracking(this);
 247800                core.Reset();
 247801                delayTimeSpan = default;
 247802                elapsed = default;
 247803                cancellationToken = default;
 247804                cancellationTokenRegistration.Dispose();
 247805                cancelImmediately = default;
 247806                return pool.TryPush(this);
 247807            }
 808        }
 809
 810        sealed class DelayIgnoreTimeScalePromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<DelayIgnoreTimeScalePr
 811        {
 812            static TaskPool<DelayIgnoreTimeScalePromise> pool;
 813            DelayIgnoreTimeScalePromise nextNode;
 0814            public ref DelayIgnoreTimeScalePromise NextNode => ref nextNode;
 815
 816            static DelayIgnoreTimeScalePromise()
 0817            {
 0818                TaskPool.RegisterSizeGetter(typeof(DelayIgnoreTimeScalePromise), () => pool.Size);
 0819            }
 820
 821            float delayFrameTimeSpan;
 822            float elapsed;
 823            int initialFrame;
 824            CancellationToken cancellationToken;
 825            CancellationTokenRegistration cancellationTokenRegistration;
 826            bool cancelImmediately;
 827
 828            UniTaskCompletionSourceCore<object> core;
 829
 0830            DelayIgnoreTimeScalePromise()
 0831            {
 0832            }
 833
 834            public static IUniTaskSource Create(TimeSpan delayFrameTimeSpan, PlayerLoopTiming timing, CancellationToken 
 0835            {
 0836                if (cancellationToken.IsCancellationRequested)
 0837                {
 0838                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 839                }
 840
 0841                if (!pool.TryPop(out var result))
 0842                {
 0843                    result = new DelayIgnoreTimeScalePromise();
 0844                }
 845
 0846                result.elapsed = 0.0f;
 0847                result.delayFrameTimeSpan = (float)delayFrameTimeSpan.TotalSeconds;
 0848                result.initialFrame = PlayerLoopHelper.IsMainThread ? Time.frameCount : -1;
 0849                result.cancellationToken = cancellationToken;
 0850                result.cancelImmediately = cancelImmediately;
 851
 0852                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0853                {
 0854                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0855                    {
 0856                        var promise = (DelayIgnoreTimeScalePromise)state;
 0857                        promise.core.TrySetCanceled(promise.cancellationToken);
 0858                    }, result);
 0859                }
 860
 0861                TaskTracker.TrackActiveTask(result, 3);
 862
 0863                PlayerLoopHelper.AddAction(timing, result);
 864
 0865                token = result.core.Version;
 0866                return result;
 0867            }
 868
 869            public void GetResult(short token)
 0870            {
 871                try
 0872                {
 0873                    core.GetResult(token);
 0874                }
 875                finally
 0876                {
 0877                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0878                    {
 0879                        TryReturn();
 0880                    }
 0881                }
 0882            }
 883
 884            public UniTaskStatus GetStatus(short token)
 0885            {
 0886                return core.GetStatus(token);
 0887            }
 888
 889            public UniTaskStatus UnsafeGetStatus()
 0890            {
 0891                return core.UnsafeGetStatus();
 0892            }
 893
 894            public void OnCompleted(Action<object> continuation, object state, short token)
 0895            {
 0896                core.OnCompleted(continuation, state, token);
 0897            }
 898
 899            public bool MoveNext()
 0900            {
 0901                if (cancellationToken.IsCancellationRequested)
 0902                {
 0903                    core.TrySetCanceled(cancellationToken);
 0904                    return false;
 905                }
 906
 0907                if (elapsed == 0.0f)
 0908                {
 0909                    if (initialFrame == Time.frameCount)
 0910                    {
 0911                        return true;
 912                    }
 0913                }
 914
 0915                elapsed += Time.unscaledDeltaTime;
 0916                if (elapsed >= delayFrameTimeSpan)
 0917                {
 0918                    core.TrySetResult(null);
 0919                    return false;
 920                }
 921
 0922                return true;
 0923            }
 924
 925            bool TryReturn()
 0926            {
 0927                TaskTracker.RemoveTracking(this);
 0928                core.Reset();
 0929                delayFrameTimeSpan = default;
 0930                elapsed = default;
 0931                cancellationToken = default;
 0932                cancellationTokenRegistration.Dispose();
 0933                cancelImmediately = default;
 0934                return pool.TryPush(this);
 0935            }
 936        }
 937
 938        sealed class DelayRealtimePromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<DelayRealtimePromise>
 939        {
 940            static TaskPool<DelayRealtimePromise> pool;
 941            DelayRealtimePromise nextNode;
 0942            public ref DelayRealtimePromise NextNode => ref nextNode;
 943
 944            static DelayRealtimePromise()
 0945            {
 0946                TaskPool.RegisterSizeGetter(typeof(DelayRealtimePromise), () => pool.Size);
 0947            }
 948
 949            long delayTimeSpanTicks;
 950            ValueStopwatch stopwatch;
 951            CancellationToken cancellationToken;
 952            CancellationTokenRegistration cancellationTokenRegistration;
 953            bool cancelImmediately;
 954
 955            UniTaskCompletionSourceCore<AsyncUnit> core;
 956
 0957            DelayRealtimePromise()
 0958            {
 0959            }
 960
 961            public static IUniTaskSource Create(TimeSpan delayTimeSpan, PlayerLoopTiming timing, CancellationToken cance
 0962            {
 0963                if (cancellationToken.IsCancellationRequested)
 0964                {
 0965                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 966                }
 967
 0968                if (!pool.TryPop(out var result))
 0969                {
 0970                    result = new DelayRealtimePromise();
 0971                }
 972
 0973                result.stopwatch = ValueStopwatch.StartNew();
 0974                result.delayTimeSpanTicks = delayTimeSpan.Ticks;
 0975                result.cancellationToken = cancellationToken;
 0976                result.cancelImmediately = cancelImmediately;
 977
 0978                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0979                {
 0980                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0981                    {
 0982                        var promise = (DelayRealtimePromise)state;
 0983                        promise.core.TrySetCanceled(promise.cancellationToken);
 0984                    }, result);
 0985                }
 986
 0987                TaskTracker.TrackActiveTask(result, 3);
 988
 0989                PlayerLoopHelper.AddAction(timing, result);
 990
 0991                token = result.core.Version;
 0992                return result;
 0993            }
 994
 995            public void GetResult(short token)
 0996            {
 997                try
 0998                {
 0999                    core.GetResult(token);
 01000                }
 1001                finally
 01002                {
 01003                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 01004                    {
 01005                        TryReturn();
 01006                    }
 01007                }
 01008            }
 1009
 1010            public UniTaskStatus GetStatus(short token)
 01011            {
 01012                return core.GetStatus(token);
 01013            }
 1014
 1015            public UniTaskStatus UnsafeGetStatus()
 01016            {
 01017                return core.UnsafeGetStatus();
 01018            }
 1019
 1020            public void OnCompleted(Action<object> continuation, object state, short token)
 01021            {
 01022                core.OnCompleted(continuation, state, token);
 01023            }
 1024
 1025            public bool MoveNext()
 01026            {
 01027                if (cancellationToken.IsCancellationRequested)
 01028                {
 01029                    core.TrySetCanceled(cancellationToken);
 01030                    return false;
 1031                }
 1032
 01033                if (stopwatch.IsInvalid)
 01034                {
 01035                    core.TrySetResult(AsyncUnit.Default);
 01036                    return false;
 1037                }
 1038
 01039                if (stopwatch.ElapsedTicks >= delayTimeSpanTicks)
 01040                {
 01041                    core.TrySetResult(AsyncUnit.Default);
 01042                    return false;
 1043                }
 1044
 01045                return true;
 01046            }
 1047
 1048            bool TryReturn()
 01049            {
 01050                TaskTracker.RemoveTracking(this);
 01051                core.Reset();
 01052                stopwatch = default;
 01053                cancellationToken = default;
 01054                cancellationTokenRegistration.Dispose();
 01055                cancelImmediately = default;
 01056                return pool.TryPush(this);
 01057            }
 1058        }
 1059    }
 1060
 1061    public readonly struct YieldAwaitable
 1062    {
 1063        readonly PlayerLoopTiming timing;
 1064
 1065        public YieldAwaitable(PlayerLoopTiming timing)
 1066        {
 1067            this.timing = timing;
 1068        }
 1069
 1070        public Awaiter GetAwaiter()
 1071        {
 1072            return new Awaiter(timing);
 1073        }
 1074
 1075        public UniTask ToUniTask()
 1076        {
 1077            return UniTask.Yield(timing, CancellationToken.None);
 1078        }
 1079
 1080        public readonly struct Awaiter : ICriticalNotifyCompletion
 1081        {
 1082            readonly PlayerLoopTiming timing;
 1083
 1084            public Awaiter(PlayerLoopTiming timing)
 1085            {
 1086                this.timing = timing;
 1087            }
 1088
 1089            public bool IsCompleted => false;
 1090
 1091            public void GetResult() { }
 1092
 1093            public void OnCompleted(Action continuation)
 1094            {
 1095                PlayerLoopHelper.AddContinuation(timing, continuation);
 1096            }
 1097
 1098            public void UnsafeOnCompleted(Action continuation)
 1099            {
 1100                PlayerLoopHelper.AddContinuation(timing, continuation);
 1101            }
 1102        }
 1103    }
 1104}

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Factory.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using Cysharp.Threading.Tasks.Internal;
 4using System;
 5using System.Runtime.CompilerServices;
 6using System.Runtime.ExceptionServices;
 7using System.Threading;
 8
 9namespace Cysharp.Threading.Tasks
 10{
 11    public partial struct UniTask
 12    {
 013        static readonly UniTask CanceledUniTask = new Func<UniTask>(() =>
 014        {
 015            return new UniTask(new CanceledResultSource(CancellationToken.None), 0);
 016        })();
 17
 18        static class CanceledUniTaskCache<T>
 19        {
 20            public static readonly UniTask<T> Task;
 21
 22            static CanceledUniTaskCache()
 23            {
 24                Task = new UniTask<T>(new CanceledResultSource<T>(CancellationToken.None), 0);
 25            }
 26        }
 27
 028        public static readonly UniTask CompletedTask = new UniTask();
 29
 30        public static UniTask FromException(Exception ex)
 031        {
 032            if (ex is OperationCanceledException oce)
 033            {
 034                return FromCanceled(oce.CancellationToken);
 35            }
 36
 037            return new UniTask(new ExceptionResultSource(ex), 0);
 038        }
 39
 40        public static UniTask<T> FromException<T>(Exception ex)
 041        {
 042            if (ex is OperationCanceledException oce)
 043            {
 044                return FromCanceled<T>(oce.CancellationToken);
 45            }
 46
 047            return new UniTask<T>(new ExceptionResultSource<T>(ex), 0);
 048        }
 49
 50        public static UniTask<T> FromResult<T>(T value)
 051        {
 052            return new UniTask<T>(value);
 053        }
 54
 55        public static UniTask FromCanceled(CancellationToken cancellationToken = default)
 056        {
 057            if (cancellationToken == CancellationToken.None)
 058            {
 059                return CanceledUniTask;
 60            }
 61            else
 062            {
 063                return new UniTask(new CanceledResultSource(cancellationToken), 0);
 64            }
 065        }
 66
 67        public static UniTask<T> FromCanceled<T>(CancellationToken cancellationToken = default)
 068        {
 069            if (cancellationToken == CancellationToken.None)
 070            {
 071                return CanceledUniTaskCache<T>.Task;
 72            }
 73            else
 074            {
 075                return new UniTask<T>(new CanceledResultSource<T>(cancellationToken), 0);
 76            }
 077        }
 78
 79        public static UniTask Create(Func<UniTask> factory)
 080        {
 081            return factory();
 082        }
 83
 84        public static UniTask<T> Create<T>(Func<UniTask<T>> factory)
 085        {
 086            return factory();
 087        }
 88
 89        public static AsyncLazy Lazy(Func<UniTask> factory)
 090        {
 091            return new AsyncLazy(factory);
 092        }
 93
 94        public static AsyncLazy<T> Lazy<T>(Func<UniTask<T>> factory)
 095        {
 096            return new AsyncLazy<T>(factory);
 097        }
 98
 99        /// <summary>
 100        /// helper of fire and forget void action.
 101        /// </summary>
 102        public static void Void(Func<UniTaskVoid> asyncAction)
 0103        {
 0104            asyncAction().Forget();
 0105        }
 106
 107        /// <summary>
 108        /// helper of fire and forget void action.
 109        /// </summary>
 110        public static void Void(Func<CancellationToken, UniTaskVoid> asyncAction, CancellationToken cancellationToken)
 0111        {
 0112            asyncAction(cancellationToken).Forget();
 0113        }
 114
 115        /// <summary>
 116        /// helper of fire and forget void action.
 117        /// </summary>
 118        public static void Void<T>(Func<T, UniTaskVoid> asyncAction, T state)
 0119        {
 0120            asyncAction(state).Forget();
 0121        }
 122
 123        /// <summary>
 124        /// helper of create add UniTaskVoid to delegate.
 125        /// For example: FooAction = UniTask.Action(async () => { /* */ })
 126        /// </summary>
 127        public static Action Action(Func<UniTaskVoid> asyncAction)
 0128        {
 0129            return () => asyncAction().Forget();
 0130        }
 131
 132        /// <summary>
 133        /// helper of create add UniTaskVoid to delegate.
 134        /// </summary>
 135        public static Action Action(Func<CancellationToken, UniTaskVoid> asyncAction, CancellationToken cancellationToke
 0136        {
 0137            return () => asyncAction(cancellationToken).Forget();
 0138        }
 139
 140#if UNITY_2018_3_OR_NEWER
 141
 142        /// <summary>
 143        /// Create async void(UniTaskVoid) UnityAction.
 144        /// For exampe: onClick.AddListener(UniTask.UnityAction(async () => { /* */ } ))
 145        /// </summary>
 146        public static UnityEngine.Events.UnityAction UnityAction(Func<UniTaskVoid> asyncAction)
 0147        {
 0148            return () => asyncAction().Forget();
 0149        }
 150
 151        /// <summary>
 152        /// Create async void(UniTaskVoid) UnityAction.
 153        /// For exampe: onClick.AddListener(UniTask.UnityAction(FooAsync, this.GetCancellationTokenOnDestroy()))
 154        /// </summary>
 155        public static UnityEngine.Events.UnityAction UnityAction(Func<CancellationToken, UniTaskVoid> asyncAction, Cance
 0156        {
 0157            return () => asyncAction(cancellationToken).Forget();
 0158        }
 159
 160#endif
 161
 162        /// <summary>
 163        /// Defer the task creation just before call await.
 164        /// </summary>
 165        public static UniTask Defer(Func<UniTask> factory)
 0166        {
 0167            return new UniTask(new DeferPromise(factory), 0);
 0168        }
 169
 170        /// <summary>
 171        /// Defer the task creation just before call await.
 172        /// </summary>
 173        public static UniTask<T> Defer<T>(Func<UniTask<T>> factory)
 0174        {
 0175            return new UniTask<T>(new DeferPromise<T>(factory), 0);
 0176        }
 177
 178        /// <summary>
 179        /// Never complete.
 180        /// </summary>
 181        public static UniTask Never(CancellationToken cancellationToken)
 0182        {
 0183            return new UniTask<AsyncUnit>(new NeverPromise<AsyncUnit>(cancellationToken), 0);
 0184        }
 185
 186        /// <summary>
 187        /// Never complete.
 188        /// </summary>
 189        public static UniTask<T> Never<T>(CancellationToken cancellationToken)
 0190        {
 0191            return new UniTask<T>(new NeverPromise<T>(cancellationToken), 0);
 0192        }
 193
 194        sealed class ExceptionResultSource : IUniTaskSource
 195        {
 196            readonly ExceptionDispatchInfo exception;
 197            bool calledGet;
 198
 0199            public ExceptionResultSource(Exception exception)
 0200            {
 0201                this.exception = ExceptionDispatchInfo.Capture(exception);
 0202            }
 203
 204            public void GetResult(short token)
 0205            {
 0206                if (!calledGet)
 0207                {
 0208                    calledGet = true;
 0209                    GC.SuppressFinalize(this);
 0210                }
 0211                exception.Throw();
 0212            }
 213
 214            public UniTaskStatus GetStatus(short token)
 0215            {
 0216                return UniTaskStatus.Faulted;
 0217            }
 218
 219            public UniTaskStatus UnsafeGetStatus()
 0220            {
 0221                return UniTaskStatus.Faulted;
 0222            }
 223
 224            public void OnCompleted(Action<object> continuation, object state, short token)
 0225            {
 0226                continuation(state);
 0227            }
 228
 229            ~ExceptionResultSource()
 0230            {
 0231                if (!calledGet)
 0232                {
 0233                    UniTaskScheduler.PublishUnobservedTaskException(exception.SourceException);
 0234                }
 0235            }
 236        }
 237
 238        sealed class ExceptionResultSource<T> : IUniTaskSource<T>
 239        {
 240            readonly ExceptionDispatchInfo exception;
 241            bool calledGet;
 242
 243            public ExceptionResultSource(Exception exception)
 244            {
 245                this.exception = ExceptionDispatchInfo.Capture(exception);
 246            }
 247
 248            public T GetResult(short token)
 249            {
 250                if (!calledGet)
 251                {
 252                    calledGet = true;
 253                    GC.SuppressFinalize(this);
 254                }
 255                exception.Throw();
 256                return default;
 257            }
 258
 259            void IUniTaskSource.GetResult(short token)
 260            {
 261                if (!calledGet)
 262                {
 263                    calledGet = true;
 264                    GC.SuppressFinalize(this);
 265                }
 266                exception.Throw();
 267            }
 268
 269            public UniTaskStatus GetStatus(short token)
 270            {
 271                return UniTaskStatus.Faulted;
 272            }
 273
 274            public UniTaskStatus UnsafeGetStatus()
 275            {
 276                return UniTaskStatus.Faulted;
 277            }
 278
 279            public void OnCompleted(Action<object> continuation, object state, short token)
 280            {
 281                continuation(state);
 282            }
 283
 284            ~ExceptionResultSource()
 285            {
 286                if (!calledGet)
 287                {
 288                    UniTaskScheduler.PublishUnobservedTaskException(exception.SourceException);
 289                }
 290            }
 291        }
 292
 293        sealed class CanceledResultSource : IUniTaskSource
 294        {
 295            readonly CancellationToken cancellationToken;
 296
 0297            public CanceledResultSource(CancellationToken cancellationToken)
 0298            {
 0299                this.cancellationToken = cancellationToken;
 0300            }
 301
 302            public void GetResult(short token)
 0303            {
 0304                throw new OperationCanceledException(cancellationToken);
 305            }
 306
 307            public UniTaskStatus GetStatus(short token)
 0308            {
 0309                return UniTaskStatus.Canceled;
 0310            }
 311
 312            public UniTaskStatus UnsafeGetStatus()
 0313            {
 0314                return UniTaskStatus.Canceled;
 0315            }
 316
 317            public void OnCompleted(Action<object> continuation, object state, short token)
 0318            {
 0319                continuation(state);
 0320            }
 321        }
 322
 323        sealed class CanceledResultSource<T> : IUniTaskSource<T>
 324        {
 325            readonly CancellationToken cancellationToken;
 326
 327            public CanceledResultSource(CancellationToken cancellationToken)
 328            {
 329                this.cancellationToken = cancellationToken;
 330            }
 331
 332            public T GetResult(short token)
 333            {
 334                throw new OperationCanceledException(cancellationToken);
 335            }
 336
 337            void IUniTaskSource.GetResult(short token)
 338            {
 339                throw new OperationCanceledException(cancellationToken);
 340            }
 341
 342            public UniTaskStatus GetStatus(short token)
 343            {
 344                return UniTaskStatus.Canceled;
 345            }
 346
 347            public UniTaskStatus UnsafeGetStatus()
 348            {
 349                return UniTaskStatus.Canceled;
 350            }
 351
 352            public void OnCompleted(Action<object> continuation, object state, short token)
 353            {
 354                continuation(state);
 355            }
 356        }
 357
 358        sealed class DeferPromise : IUniTaskSource
 359        {
 360            Func<UniTask> factory;
 361            UniTask task;
 362            UniTask.Awaiter awaiter;
 363
 0364            public DeferPromise(Func<UniTask> factory)
 0365            {
 0366                this.factory = factory;
 0367            }
 368
 369            public void GetResult(short token)
 0370            {
 0371                awaiter.GetResult();
 0372            }
 373
 374            public UniTaskStatus GetStatus(short token)
 0375            {
 0376                var f = Interlocked.Exchange(ref factory, null);
 0377                if (f != null)
 0378                {
 0379                    task = f();
 0380                    awaiter = task.GetAwaiter();
 0381                }
 382
 0383                return task.Status;
 0384            }
 385
 386            public void OnCompleted(Action<object> continuation, object state, short token)
 0387            {
 0388                awaiter.SourceOnCompleted(continuation, state);
 0389            }
 390
 391            public UniTaskStatus UnsafeGetStatus()
 0392            {
 0393                return task.Status;
 0394            }
 395        }
 396
 397        sealed class DeferPromise<T> : IUniTaskSource<T>
 398        {
 399            Func<UniTask<T>> factory;
 400            UniTask<T> task;
 401            UniTask<T>.Awaiter awaiter;
 402
 403            public DeferPromise(Func<UniTask<T>> factory)
 404            {
 405                this.factory = factory;
 406            }
 407
 408            public T GetResult(short token)
 409            {
 410                return awaiter.GetResult();
 411            }
 412
 413            void IUniTaskSource.GetResult(short token)
 414            {
 415                awaiter.GetResult();
 416            }
 417
 418            public UniTaskStatus GetStatus(short token)
 419            {
 420                var f = Interlocked.Exchange(ref factory, null);
 421                if (f != null)
 422                {
 423                    task = f();
 424                    awaiter = task.GetAwaiter();
 425                }
 426
 427                return task.Status;
 428            }
 429
 430            public void OnCompleted(Action<object> continuation, object state, short token)
 431            {
 432                awaiter.SourceOnCompleted(continuation, state);
 433            }
 434
 435            public UniTaskStatus UnsafeGetStatus()
 436            {
 437                return task.Status;
 438            }
 439        }
 440
 441        sealed class NeverPromise<T> : IUniTaskSource<T>
 442        {
 443            static readonly Action<object> cancellationCallback = CancellationCallback;
 444
 445            CancellationToken cancellationToken;
 446            UniTaskCompletionSourceCore<T> core;
 447
 448            public NeverPromise(CancellationToken cancellationToken)
 449            {
 450                this.cancellationToken = cancellationToken;
 451                if (this.cancellationToken.CanBeCanceled)
 452                {
 453                    this.cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this);
 454                }
 455            }
 456
 457            static void CancellationCallback(object state)
 458            {
 459                var self = (NeverPromise<T>)state;
 460                self.core.TrySetCanceled(self.cancellationToken);
 461            }
 462
 463            public T GetResult(short token)
 464            {
 465                return core.GetResult(token);
 466            }
 467
 468            public UniTaskStatus GetStatus(short token)
 469            {
 470                return core.GetStatus(token);
 471            }
 472
 473            public UniTaskStatus UnsafeGetStatus()
 474            {
 475                return core.UnsafeGetStatus();
 476            }
 477
 478            public void OnCompleted(Action<object> continuation, object state, short token)
 479            {
 480                core.OnCompleted(continuation, state, token);
 481            }
 482
 483            void IUniTaskSource.GetResult(short token)
 484            {
 485                core.GetResult(token);
 486            }
 487        }
 488    }
 489
 490    internal static class CompletedTasks
 491    {
 492        public static readonly UniTask<AsyncUnit> AsyncUnit = UniTask.FromResult(Cysharp.Threading.Tasks.AsyncUnit.Defau
 493        public static readonly UniTask<bool> True = UniTask.FromResult(true);
 494        public static readonly UniTask<bool> False = UniTask.FromResult(false);
 495        public static readonly UniTask<int> Zero = UniTask.FromResult(0);
 496        public static readonly UniTask<int> MinusOne = UniTask.FromResult(-1);
 497        public static readonly UniTask<int> One = UniTask.FromResult(1);
 498    }
 499}

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Run.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using System;
 4using System.Threading;
 5
 6namespace Cysharp.Threading.Tasks
 7{
 8    public partial struct UniTask
 9    {
 10        #region OBSOLETE_RUN
 11
 12        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 13        public static UniTask Run(Action action, bool configureAwait = true, CancellationToken cancellationToken = defau
 014        {
 015            return RunOnThreadPool(action, configureAwait, cancellationToken);
 016        }
 17
 18        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 19        public static UniTask Run(Action<object> action, object state, bool configureAwait = true, CancellationToken can
 020        {
 021            return RunOnThreadPool(action, state, configureAwait, cancellationToken);
 022        }
 23
 24        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 25        public static UniTask Run(Func<UniTask> action, bool configureAwait = true, CancellationToken cancellationToken 
 026        {
 027            return RunOnThreadPool(action, configureAwait, cancellationToken);
 028        }
 29
 30        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 31        public static UniTask Run(Func<object, UniTask> action, object state, bool configureAwait = true, CancellationTo
 032        {
 033            return RunOnThreadPool(action, state, configureAwait, cancellationToken);
 034        }
 35
 36        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 37        public static UniTask<T> Run<T>(Func<T> func, bool configureAwait = true, CancellationToken cancellationToken = 
 038        {
 039            return RunOnThreadPool(func, configureAwait, cancellationToken);
 040        }
 41
 42        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 43        public static UniTask<T> Run<T>(Func<UniTask<T>> func, bool configureAwait = true, CancellationToken cancellatio
 044        {
 045            return RunOnThreadPool(func, configureAwait, cancellationToken);
 046        }
 47
 48        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 49        public static UniTask<T> Run<T>(Func<object, T> func, object state, bool configureAwait = true, CancellationToke
 050        {
 051            return RunOnThreadPool(func, state, configureAwait, cancellationToken);
 052        }
 53
 54        [Obsolete("UniTask.Run is similar as Task.Run, it uses ThreadPool. For equivalent behaviour, use UniTask.RunOnTh
 55        public static UniTask<T> Run<T>(Func<object, UniTask<T>> func, object state, bool configureAwait = true, Cancell
 056        {
 057            return RunOnThreadPool(func, state, configureAwait, cancellationToken);
 058        }
 59
 60        #endregion
 61
 62        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 63        public static async UniTask RunOnThreadPool(Action action, bool configureAwait = true, CancellationToken cancell
 064        {
 065            cancellationToken.ThrowIfCancellationRequested();
 66
 067            await UniTask.SwitchToThreadPool();
 68
 069            cancellationToken.ThrowIfCancellationRequested();
 70
 071            if (configureAwait)
 072            {
 73                try
 074                {
 075                    action();
 076                }
 77                finally
 078                {
 079                    await UniTask.Yield();
 080                }
 081            }
 82            else
 083            {
 084                action();
 085            }
 86
 087            cancellationToken.ThrowIfCancellationRequested();
 088        }
 89
 90        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 91        public static async UniTask RunOnThreadPool(Action<object> action, object state, bool configureAwait = true, Can
 092        {
 093            cancellationToken.ThrowIfCancellationRequested();
 94
 095            await UniTask.SwitchToThreadPool();
 96
 097            cancellationToken.ThrowIfCancellationRequested();
 98
 099            if (configureAwait)
 0100            {
 101                try
 0102                {
 0103                    action(state);
 0104                }
 105                finally
 0106                {
 0107                    await UniTask.Yield();
 0108                }
 0109            }
 110            else
 0111            {
 0112                action(state);
 0113            }
 114
 0115            cancellationToken.ThrowIfCancellationRequested();
 0116        }
 117
 118        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 119        public static async UniTask RunOnThreadPool(Func<UniTask> action, bool configureAwait = true, CancellationToken 
 0120        {
 0121            cancellationToken.ThrowIfCancellationRequested();
 122
 0123            await UniTask.SwitchToThreadPool();
 124
 0125            cancellationToken.ThrowIfCancellationRequested();
 126
 0127            if (configureAwait)
 0128            {
 129                try
 0130                {
 0131                    await action();
 0132                }
 133                finally
 0134                {
 0135                    await UniTask.Yield();
 0136                }
 0137            }
 138            else
 0139            {
 0140                await action();
 0141            }
 142
 0143            cancellationToken.ThrowIfCancellationRequested();
 0144        }
 145
 146        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 147        public static async UniTask RunOnThreadPool(Func<object, UniTask> action, object state, bool configureAwait = tr
 0148        {
 0149            cancellationToken.ThrowIfCancellationRequested();
 150
 0151            await UniTask.SwitchToThreadPool();
 152
 0153            cancellationToken.ThrowIfCancellationRequested();
 154
 0155            if (configureAwait)
 0156            {
 157                try
 0158                {
 0159                    await action(state);
 0160                }
 161                finally
 0162                {
 0163                    await UniTask.Yield();
 0164                }
 0165            }
 166            else
 0167            {
 0168                await action(state);
 0169            }
 170
 0171            cancellationToken.ThrowIfCancellationRequested();
 0172        }
 173
 174        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 175        public static async UniTask<T> RunOnThreadPool<T>(Func<T> func, bool configureAwait = true, CancellationToken ca
 176        {
 177            cancellationToken.ThrowIfCancellationRequested();
 178
 179            await UniTask.SwitchToThreadPool();
 180
 181            cancellationToken.ThrowIfCancellationRequested();
 182
 183            if (configureAwait)
 184            {
 185                try
 186                {
 187                    return func();
 188                }
 189                finally
 190                {
 191                    await UniTask.Yield();
 192                    cancellationToken.ThrowIfCancellationRequested();
 193                }
 194            }
 195            else
 196            {
 197                return func();
 198            }
 199        }
 200
 201        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 202        public static async UniTask<T> RunOnThreadPool<T>(Func<UniTask<T>> func, bool configureAwait = true, Cancellatio
 203        {
 204            cancellationToken.ThrowIfCancellationRequested();
 205
 206            await UniTask.SwitchToThreadPool();
 207
 208            cancellationToken.ThrowIfCancellationRequested();
 209
 210            if (configureAwait)
 211            {
 212                try
 213                {
 214                    return await func();
 215                }
 216                finally
 217                {
 218                    cancellationToken.ThrowIfCancellationRequested();
 219                    await UniTask.Yield();
 220                    cancellationToken.ThrowIfCancellationRequested();
 221                }
 222            }
 223            else
 224            {
 225                var result = await func();
 226                cancellationToken.ThrowIfCancellationRequested();
 227                return result;
 228            }
 229        }
 230
 231        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 232        public static async UniTask<T> RunOnThreadPool<T>(Func<object, T> func, object state, bool configureAwait = true
 233        {
 234            cancellationToken.ThrowIfCancellationRequested();
 235
 236            await UniTask.SwitchToThreadPool();
 237
 238            cancellationToken.ThrowIfCancellationRequested();
 239
 240            if (configureAwait)
 241            {
 242                try
 243                {
 244                    return func(state);
 245                }
 246                finally
 247                {
 248                    await UniTask.Yield();
 249                    cancellationToken.ThrowIfCancellationRequested();
 250                }
 251            }
 252            else
 253            {
 254                return func(state);
 255            }
 256        }
 257
 258        /// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary>
 259        public static async UniTask<T> RunOnThreadPool<T>(Func<object, UniTask<T>> func, object state, bool configureAwa
 260        {
 261            cancellationToken.ThrowIfCancellationRequested();
 262
 263            await UniTask.SwitchToThreadPool();
 264
 265            cancellationToken.ThrowIfCancellationRequested();
 266
 267            if (configureAwait)
 268            {
 269                try
 270                {
 271                    return await func(state);
 272                }
 273                finally
 274                {
 275                    cancellationToken.ThrowIfCancellationRequested();
 276                    await UniTask.Yield();
 277                    cancellationToken.ThrowIfCancellationRequested();
 278                }
 279            }
 280            else
 281            {
 282                var result = await func(state);
 283                cancellationToken.ThrowIfCancellationRequested();
 284                return result;
 285            }
 286        }
 287    }
 288}
 289

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.Threading.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using System;
 4using System.Runtime.CompilerServices;
 5using System.Threading;
 6using System.Threading.Tasks;
 7using Cysharp.Threading.Tasks.Internal;
 8
 9namespace Cysharp.Threading.Tasks
 10{
 11    public partial struct UniTask
 12    {
 13#if UNITY_2018_3_OR_NEWER
 14
 15        /// <summary>
 16        /// If running on mainthread, do nothing. Otherwise, same as UniTask.Yield(PlayerLoopTiming.Update).
 17        /// </summary>
 18        public static SwitchToMainThreadAwaitable SwitchToMainThread(CancellationToken cancellationToken = default)
 019        {
 020            return new SwitchToMainThreadAwaitable(PlayerLoopTiming.Update, cancellationToken);
 021        }
 22
 23        /// <summary>
 24        /// If running on mainthread, do nothing. Otherwise, same as UniTask.Yield(timing).
 25        /// </summary>
 26        public static SwitchToMainThreadAwaitable SwitchToMainThread(PlayerLoopTiming timing, CancellationToken cancella
 027        {
 028            return new SwitchToMainThreadAwaitable(timing, cancellationToken);
 029        }
 30
 31        /// <summary>
 32        /// Return to mainthread(same as await SwitchToMainThread) after using scope is closed.
 33        /// </summary>
 34        public static ReturnToMainThread ReturnToMainThread(CancellationToken cancellationToken = default)
 035        {
 036            return new ReturnToMainThread(PlayerLoopTiming.Update, cancellationToken);
 037        }
 38
 39        /// <summary>
 40        /// Return to mainthread(same as await SwitchToMainThread) after using scope is closed.
 41        /// </summary>
 42        public static ReturnToMainThread ReturnToMainThread(PlayerLoopTiming timing, CancellationToken cancellationToken
 043        {
 044            return new ReturnToMainThread(timing, cancellationToken);
 045        }
 46
 47        /// <summary>
 48        /// Queue the action to PlayerLoop.
 49        /// </summary>
 50        public static void Post(Action action, PlayerLoopTiming timing = PlayerLoopTiming.Update)
 051        {
 052            PlayerLoopHelper.AddContinuation(timing, action);
 053        }
 54
 55#endif
 56
 57        public static SwitchToThreadPoolAwaitable SwitchToThreadPool()
 058        {
 059            return new SwitchToThreadPoolAwaitable();
 060        }
 61
 62        /// <summary>
 63        /// Note: use SwitchToThreadPool is recommended.
 64        /// </summary>
 65        public static SwitchToTaskPoolAwaitable SwitchToTaskPool()
 066        {
 067            return new SwitchToTaskPoolAwaitable();
 068        }
 69
 70        public static SwitchToSynchronizationContextAwaitable SwitchToSynchronizationContext(SynchronizationContext sync
 071        {
 072            Error.ThrowArgumentNullException(synchronizationContext, nameof(synchronizationContext));
 073            return new SwitchToSynchronizationContextAwaitable(synchronizationContext, cancellationToken);
 074        }
 75
 76        public static ReturnToSynchronizationContext ReturnToSynchronizationContext(SynchronizationContext synchronizati
 077        {
 078            return new ReturnToSynchronizationContext(synchronizationContext, false, cancellationToken);
 079        }
 80
 81        public static ReturnToSynchronizationContext ReturnToCurrentSynchronizationContext(bool dontPostWhenSameContext 
 082        {
 083            return new ReturnToSynchronizationContext(SynchronizationContext.Current, dontPostWhenSameContext, cancellat
 084        }
 85    }
 86
 87#if UNITY_2018_3_OR_NEWER
 88
 89    public struct SwitchToMainThreadAwaitable
 90    {
 91        readonly PlayerLoopTiming playerLoopTiming;
 92        readonly CancellationToken cancellationToken;
 93
 94        public SwitchToMainThreadAwaitable(PlayerLoopTiming playerLoopTiming, CancellationToken cancellationToken)
 95        {
 96            this.playerLoopTiming = playerLoopTiming;
 97            this.cancellationToken = cancellationToken;
 98        }
 99
 100        public Awaiter GetAwaiter() => new Awaiter(playerLoopTiming, cancellationToken);
 101
 102        public struct Awaiter : ICriticalNotifyCompletion
 103        {
 104            readonly PlayerLoopTiming playerLoopTiming;
 105            readonly CancellationToken cancellationToken;
 106
 107            public Awaiter(PlayerLoopTiming playerLoopTiming, CancellationToken cancellationToken)
 108            {
 109                this.playerLoopTiming = playerLoopTiming;
 110                this.cancellationToken = cancellationToken;
 111            }
 112
 113            public bool IsCompleted
 114            {
 115                get
 116                {
 117                    var currentThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
 118                    if (PlayerLoopHelper.MainThreadId == currentThreadId)
 119                    {
 120                        return true; // run immediate.
 121                    }
 122                    else
 123                    {
 124                        return false; // register continuation.
 125                    }
 126                }
 127            }
 128
 129            public void GetResult() { cancellationToken.ThrowIfCancellationRequested(); }
 130
 131            public void OnCompleted(Action continuation)
 132            {
 133                PlayerLoopHelper.AddContinuation(playerLoopTiming, continuation);
 134            }
 135
 136            public void UnsafeOnCompleted(Action continuation)
 137            {
 138                PlayerLoopHelper.AddContinuation(playerLoopTiming, continuation);
 139            }
 140        }
 141    }
 142
 143    public struct ReturnToMainThread
 144    {
 145        readonly PlayerLoopTiming playerLoopTiming;
 146        readonly CancellationToken cancellationToken;
 147
 148        public ReturnToMainThread(PlayerLoopTiming playerLoopTiming, CancellationToken cancellationToken)
 149        {
 150            this.playerLoopTiming = playerLoopTiming;
 151            this.cancellationToken = cancellationToken;
 152        }
 153
 154        public Awaiter DisposeAsync()
 155        {
 156            return new Awaiter(playerLoopTiming, cancellationToken); // run immediate.
 157        }
 158
 159        public readonly struct Awaiter : ICriticalNotifyCompletion
 160        {
 161            readonly PlayerLoopTiming timing;
 162            readonly CancellationToken cancellationToken;
 163
 164            public Awaiter(PlayerLoopTiming timing, CancellationToken cancellationToken)
 165            {
 166                this.timing = timing;
 167                this.cancellationToken = cancellationToken;
 168            }
 169
 170            public Awaiter GetAwaiter() => this;
 171
 172            public bool IsCompleted => PlayerLoopHelper.MainThreadId == System.Threading.Thread.CurrentThread.ManagedThr
 173
 174            public void GetResult() { cancellationToken.ThrowIfCancellationRequested(); }
 175
 176            public void OnCompleted(Action continuation)
 177            {
 178                PlayerLoopHelper.AddContinuation(timing, continuation);
 179            }
 180
 181            public void UnsafeOnCompleted(Action continuation)
 182            {
 183                PlayerLoopHelper.AddContinuation(timing, continuation);
 184            }
 185        }
 186    }
 187
 188#endif
 189
 190    public struct SwitchToThreadPoolAwaitable
 191    {
 192        public Awaiter GetAwaiter() => new Awaiter();
 193
 194        public struct Awaiter : ICriticalNotifyCompletion
 195        {
 196            static readonly WaitCallback switchToCallback = Callback;
 197
 198            public bool IsCompleted => false;
 199            public void GetResult() { }
 200
 201            public void OnCompleted(Action continuation)
 202            {
 203                ThreadPool.QueueUserWorkItem(switchToCallback, continuation);
 204            }
 205
 206            public void UnsafeOnCompleted(Action continuation)
 207            {
 208#if NETCOREAPP3_1
 209                ThreadPool.UnsafeQueueUserWorkItem(ThreadPoolWorkItem.Create(continuation), false);
 210#else
 211                ThreadPool.UnsafeQueueUserWorkItem(switchToCallback, continuation);
 212#endif
 213            }
 214
 215            static void Callback(object state)
 216            {
 217                var continuation = (Action)state;
 218                continuation();
 219            }
 220        }
 221
 222#if NETCOREAPP3_1
 223
 224        sealed class ThreadPoolWorkItem : IThreadPoolWorkItem, ITaskPoolNode<ThreadPoolWorkItem>
 225        {
 226            static TaskPool<ThreadPoolWorkItem> pool;
 227            ThreadPoolWorkItem nextNode;
 228            public ref ThreadPoolWorkItem NextNode => ref nextNode;
 229
 230            static ThreadPoolWorkItem()
 231            {
 232                TaskPool.RegisterSizeGetter(typeof(ThreadPoolWorkItem), () => pool.Size);
 233            }
 234
 235            Action continuation;
 236
 237            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 238            public static ThreadPoolWorkItem Create(Action continuation)
 239            {
 240                if (!pool.TryPop(out var item))
 241                {
 242                    item = new ThreadPoolWorkItem();
 243                }
 244
 245                item.continuation = continuation;
 246                return item;
 247            }
 248
 249            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 250            public void Execute()
 251            {
 252                var call = continuation;
 253                continuation = null;
 254                if (call != null)
 255                {
 256                    pool.TryPush(this);
 257                    call.Invoke();
 258                }
 259            }
 260        }
 261
 262#endif
 263    }
 264
 265    public struct SwitchToTaskPoolAwaitable
 266    {
 267        public Awaiter GetAwaiter() => new Awaiter();
 268
 269        public struct Awaiter : ICriticalNotifyCompletion
 270        {
 271            static readonly Action<object> switchToCallback = Callback;
 272
 273            public bool IsCompleted => false;
 274            public void GetResult() { }
 275
 276            public void OnCompleted(Action continuation)
 277            {
 278                Task.Factory.StartNew(switchToCallback, continuation, CancellationToken.None, TaskCreationOptions.DenyCh
 279            }
 280
 281            public void UnsafeOnCompleted(Action continuation)
 282            {
 283                Task.Factory.StartNew(switchToCallback, continuation, CancellationToken.None, TaskCreationOptions.DenyCh
 284            }
 285
 286            static void Callback(object state)
 287            {
 288                var continuation = (Action)state;
 289                continuation();
 290            }
 291        }
 292    }
 293
 294    public struct SwitchToSynchronizationContextAwaitable
 295    {
 296        readonly SynchronizationContext synchronizationContext;
 297        readonly CancellationToken cancellationToken;
 298
 299        public SwitchToSynchronizationContextAwaitable(SynchronizationContext synchronizationContext, CancellationToken 
 300        {
 301            this.synchronizationContext = synchronizationContext;
 302            this.cancellationToken = cancellationToken;
 303        }
 304
 305        public Awaiter GetAwaiter() => new Awaiter(synchronizationContext, cancellationToken);
 306
 307        public struct Awaiter : ICriticalNotifyCompletion
 308        {
 309            static readonly SendOrPostCallback switchToCallback = Callback;
 310            readonly SynchronizationContext synchronizationContext;
 311            readonly CancellationToken cancellationToken;
 312
 313            public Awaiter(SynchronizationContext synchronizationContext, CancellationToken cancellationToken)
 314            {
 315                this.synchronizationContext = synchronizationContext;
 316                this.cancellationToken = cancellationToken;
 317            }
 318
 319            public bool IsCompleted => false;
 320            public void GetResult() { cancellationToken.ThrowIfCancellationRequested(); }
 321
 322            public void OnCompleted(Action continuation)
 323            {
 324                synchronizationContext.Post(switchToCallback, continuation);
 325            }
 326
 327            public void UnsafeOnCompleted(Action continuation)
 328            {
 329                synchronizationContext.Post(switchToCallback, continuation);
 330            }
 331
 332            static void Callback(object state)
 333            {
 334                var continuation = (Action)state;
 335                continuation();
 336            }
 337        }
 338    }
 339
 340    public struct ReturnToSynchronizationContext
 341    {
 342        readonly SynchronizationContext syncContext;
 343        readonly bool dontPostWhenSameContext;
 344        readonly CancellationToken cancellationToken;
 345
 346        public ReturnToSynchronizationContext(SynchronizationContext syncContext, bool dontPostWhenSameContext, Cancella
 347        {
 348            this.syncContext = syncContext;
 349            this.dontPostWhenSameContext = dontPostWhenSameContext;
 350            this.cancellationToken = cancellationToken;
 351        }
 352
 353        public Awaiter DisposeAsync()
 354        {
 355            return new Awaiter(syncContext, dontPostWhenSameContext, cancellationToken);
 356        }
 357
 358        public struct Awaiter : ICriticalNotifyCompletion
 359        {
 360            static readonly SendOrPostCallback switchToCallback = Callback;
 361
 362            readonly SynchronizationContext synchronizationContext;
 363            readonly bool dontPostWhenSameContext;
 364            readonly CancellationToken cancellationToken;
 365
 366            public Awaiter(SynchronizationContext synchronizationContext, bool dontPostWhenSameContext, CancellationToke
 367            {
 368                this.synchronizationContext = synchronizationContext;
 369                this.dontPostWhenSameContext = dontPostWhenSameContext;
 370                this.cancellationToken = cancellationToken;
 371            }
 372
 373            public Awaiter GetAwaiter() => this;
 374
 375            public bool IsCompleted
 376            {
 377                get
 378                {
 379                    if (!dontPostWhenSameContext) return false;
 380
 381                    var current = SynchronizationContext.Current;
 382                    if (current == synchronizationContext)
 383                    {
 384                        return true;
 385                    }
 386                    else
 387                    {
 388                        return false;
 389                    }
 390                }
 391            }
 392
 393            public void GetResult() { cancellationToken.ThrowIfCancellationRequested(); }
 394
 395            public void OnCompleted(Action continuation)
 396            {
 397                synchronizationContext.Post(switchToCallback, continuation);
 398            }
 399
 400            public void UnsafeOnCompleted(Action continuation)
 401            {
 402                synchronizationContext.Post(switchToCallback, continuation);
 403            }
 404
 405            static void Callback(object state)
 406            {
 407                var continuation = (Action)state;
 408                continuation();
 409            }
 410        }
 411    }
 412}

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WaitUntil.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Threading;
 6using Cysharp.Threading.Tasks.Internal;
 7
 8namespace Cysharp.Threading.Tasks
 9{
 10    public partial struct UniTask
 11    {
 12        public static UniTask WaitUntil(Func<bool> predicate, PlayerLoopTiming timing = PlayerLoopTiming.Update, Cancell
 013        {
 014            return new UniTask(WaitUntilPromise.Create(predicate, timing, cancellationToken, cancelImmediately, out var 
 015        }
 16
 17        public static UniTask WaitWhile(Func<bool> predicate, PlayerLoopTiming timing = PlayerLoopTiming.Update, Cancell
 018        {
 019            return new UniTask(WaitWhilePromise.Create(predicate, timing, cancellationToken, cancelImmediately, out var 
 020        }
 21
 22        public static UniTask WaitUntilCanceled(CancellationToken cancellationToken, PlayerLoopTiming timing = PlayerLoo
 023        {
 024            return new UniTask(WaitUntilCanceledPromise.Create(cancellationToken, timing, completeImmediately, out var t
 025        }
 26
 27        public static UniTask<U> WaitUntilValueChanged<T, U>(T target, Func<T, U> monitorFunction, PlayerLoopTiming moni
 28          where T : class
 029        {
 030            var unityObject = target as UnityEngine.Object;
 031            var isUnityObject = target is UnityEngine.Object; // don't use (unityObject == null)
 32
 033            return new UniTask<U>(isUnityObject
 34                ? WaitUntilValueChangedUnityObjectPromise<T, U>.Create(target, monitorFunction, equalityComparer, monito
 35                : WaitUntilValueChangedStandardObjectPromise<T, U>.Create(target, monitorFunction, equalityComparer, mon
 036        }
 37
 38        sealed class WaitUntilPromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<WaitUntilPromise>
 39        {
 40            static TaskPool<WaitUntilPromise> pool;
 41            WaitUntilPromise nextNode;
 042            public ref WaitUntilPromise NextNode => ref nextNode;
 43
 44            static WaitUntilPromise()
 045            {
 046                TaskPool.RegisterSizeGetter(typeof(WaitUntilPromise), () => pool.Size);
 047            }
 48
 49            Func<bool> predicate;
 50            CancellationToken cancellationToken;
 51            CancellationTokenRegistration cancellationTokenRegistration;
 52            bool cancelImmediately;
 53
 54            UniTaskCompletionSourceCore<object> core;
 55
 056            WaitUntilPromise()
 057            {
 058            }
 59
 60            public static IUniTaskSource Create(Func<bool> predicate, PlayerLoopTiming timing, CancellationToken cancell
 061            {
 062                if (cancellationToken.IsCancellationRequested)
 063                {
 064                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 65                }
 66
 067                if (!pool.TryPop(out var result))
 068                {
 069                    result = new WaitUntilPromise();
 070                }
 71
 072                result.predicate = predicate;
 073                result.cancellationToken = cancellationToken;
 074                result.cancelImmediately = cancelImmediately;
 75
 076                if (cancelImmediately && cancellationToken.CanBeCanceled)
 077                {
 078                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 079                    {
 080                        var promise = (WaitUntilPromise)state;
 081                        promise.core.TrySetCanceled(promise.cancellationToken);
 082                    }, result);
 083                }
 84
 085                TaskTracker.TrackActiveTask(result, 3);
 86
 087                PlayerLoopHelper.AddAction(timing, result);
 88
 089                token = result.core.Version;
 090                return result;
 091            }
 92
 93            public void GetResult(short token)
 094            {
 95                try
 096                {
 097                    core.GetResult(token);
 098                }
 99                finally
 0100                {
 0101                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0102                    {
 0103                        TryReturn();
 0104                    }
 0105                }
 0106            }
 107
 108            public UniTaskStatus GetStatus(short token)
 0109            {
 0110                return core.GetStatus(token);
 0111            }
 112
 113            public UniTaskStatus UnsafeGetStatus()
 0114            {
 0115                return core.UnsafeGetStatus();
 0116            }
 117
 118            public void OnCompleted(Action<object> continuation, object state, short token)
 0119            {
 0120                core.OnCompleted(continuation, state, token);
 0121            }
 122
 123            public bool MoveNext()
 0124            {
 0125                if (cancellationToken.IsCancellationRequested)
 0126                {
 0127                    core.TrySetCanceled(cancellationToken);
 0128                    return false;
 129                }
 130
 131                try
 0132                {
 0133                    if (!predicate())
 0134                    {
 0135                        return true;
 136                    }
 0137                }
 0138                catch (Exception ex)
 0139                {
 0140                    core.TrySetException(ex);
 0141                    return false;
 142                }
 143
 0144                core.TrySetResult(null);
 0145                return false;
 0146            }
 147
 148            bool TryReturn()
 0149            {
 0150                TaskTracker.RemoveTracking(this);
 0151                core.Reset();
 0152                predicate = default;
 0153                cancellationToken = default;
 0154                cancellationTokenRegistration.Dispose();
 0155                cancelImmediately = default;
 0156                return pool.TryPush(this);
 0157            }
 158        }
 159
 160        sealed class WaitWhilePromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<WaitWhilePromise>
 161        {
 162            static TaskPool<WaitWhilePromise> pool;
 163            WaitWhilePromise nextNode;
 0164            public ref WaitWhilePromise NextNode => ref nextNode;
 165
 166            static WaitWhilePromise()
 0167            {
 0168                TaskPool.RegisterSizeGetter(typeof(WaitWhilePromise), () => pool.Size);
 0169            }
 170
 171            Func<bool> predicate;
 172            CancellationToken cancellationToken;
 173            CancellationTokenRegistration cancellationTokenRegistration;
 174            bool cancelImmediately;
 175
 176            UniTaskCompletionSourceCore<object> core;
 177
 0178            WaitWhilePromise()
 0179            {
 0180            }
 181
 182            public static IUniTaskSource Create(Func<bool> predicate, PlayerLoopTiming timing, CancellationToken cancell
 0183            {
 0184                if (cancellationToken.IsCancellationRequested)
 0185                {
 0186                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 187                }
 188
 0189                if (!pool.TryPop(out var result))
 0190                {
 0191                    result = new WaitWhilePromise();
 0192                }
 193
 0194                result.predicate = predicate;
 0195                result.cancellationToken = cancellationToken;
 196
 0197                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0198                {
 0199                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0200                    {
 0201                        var promise = (WaitWhilePromise)state;
 0202                        promise.core.TrySetCanceled(promise.cancellationToken);
 0203                    }, result);
 0204                }
 205
 0206                TaskTracker.TrackActiveTask(result, 3);
 207
 0208                PlayerLoopHelper.AddAction(timing, result);
 209
 0210                token = result.core.Version;
 0211                return result;
 0212            }
 213
 214            public void GetResult(short token)
 0215            {
 216                try
 0217                {
 0218                    core.GetResult(token);
 0219                }
 220                finally
 0221                {
 0222                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0223                    {
 0224                        TryReturn();
 0225                    }
 0226                }
 0227            }
 228
 229            public UniTaskStatus GetStatus(short token)
 0230            {
 0231                return core.GetStatus(token);
 0232            }
 233
 234            public UniTaskStatus UnsafeGetStatus()
 0235            {
 0236                return core.UnsafeGetStatus();
 0237            }
 238
 239            public void OnCompleted(Action<object> continuation, object state, short token)
 0240            {
 0241                core.OnCompleted(continuation, state, token);
 0242            }
 243
 244            public bool MoveNext()
 0245            {
 0246                if (cancellationToken.IsCancellationRequested)
 0247                {
 0248                    core.TrySetCanceled(cancellationToken);
 0249                    return false;
 250                }
 251
 252                try
 0253                {
 0254                    if (predicate())
 0255                    {
 0256                        return true;
 257                    }
 0258                }
 0259                catch (Exception ex)
 0260                {
 0261                    core.TrySetException(ex);
 0262                    return false;
 263                }
 264
 0265                core.TrySetResult(null);
 0266                return false;
 0267            }
 268
 269            bool TryReturn()
 0270            {
 0271                TaskTracker.RemoveTracking(this);
 0272                core.Reset();
 0273                predicate = default;
 0274                cancellationToken = default;
 0275                cancellationTokenRegistration.Dispose();
 0276                cancelImmediately = default;
 0277                return pool.TryPush(this);
 0278            }
 279        }
 280
 281        sealed class WaitUntilCanceledPromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<WaitUntilCanceledPromise>
 282        {
 283            static TaskPool<WaitUntilCanceledPromise> pool;
 284            WaitUntilCanceledPromise nextNode;
 0285            public ref WaitUntilCanceledPromise NextNode => ref nextNode;
 286
 287            static WaitUntilCanceledPromise()
 0288            {
 0289                TaskPool.RegisterSizeGetter(typeof(WaitUntilCanceledPromise), () => pool.Size);
 0290            }
 291
 292            CancellationToken cancellationToken;
 293            CancellationTokenRegistration cancellationTokenRegistration;
 294            bool cancelImmediately;
 295
 296            UniTaskCompletionSourceCore<object> core;
 297
 0298            WaitUntilCanceledPromise()
 0299            {
 0300            }
 301
 302            public static IUniTaskSource Create(CancellationToken cancellationToken, PlayerLoopTiming timing, bool cance
 0303            {
 0304                if (cancellationToken.IsCancellationRequested)
 0305                {
 0306                    return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
 307                }
 308
 0309                if (!pool.TryPop(out var result))
 0310                {
 0311                    result = new WaitUntilCanceledPromise();
 0312                }
 313
 0314                result.cancellationToken = cancellationToken;
 0315                result.cancelImmediately = cancelImmediately;
 316
 0317                if (cancelImmediately && cancellationToken.CanBeCanceled)
 0318                {
 0319                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 0320                    {
 0321                        var promise = (WaitUntilCanceledPromise)state;
 0322                        promise.core.TrySetResult(null);
 0323                    }, result);
 0324                }
 325
 0326                TaskTracker.TrackActiveTask(result, 3);
 327
 0328                PlayerLoopHelper.AddAction(timing, result);
 329
 0330                token = result.core.Version;
 0331                return result;
 0332            }
 333
 334            public void GetResult(short token)
 0335            {
 336                try
 0337                {
 0338                    core.GetResult(token);
 0339                }
 340                finally
 0341                {
 0342                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 0343                    {
 0344                        TryReturn();
 0345                    }
 0346                }
 0347            }
 348
 349            public UniTaskStatus GetStatus(short token)
 0350            {
 0351                return core.GetStatus(token);
 0352            }
 353
 354            public UniTaskStatus UnsafeGetStatus()
 0355            {
 0356                return core.UnsafeGetStatus();
 0357            }
 358
 359            public void OnCompleted(Action<object> continuation, object state, short token)
 0360            {
 0361                core.OnCompleted(continuation, state, token);
 0362            }
 363
 364            public bool MoveNext()
 0365            {
 0366                if (cancellationToken.IsCancellationRequested)
 0367                {
 0368                    core.TrySetResult(null);
 0369                    return false;
 370                }
 371
 0372                return true;
 0373            }
 374
 375            bool TryReturn()
 0376            {
 0377                TaskTracker.RemoveTracking(this);
 0378                core.Reset();
 0379                cancellationToken = default;
 0380                cancellationTokenRegistration.Dispose();
 0381                cancelImmediately = default;
 0382                return pool.TryPush(this);
 0383            }
 384        }
 385
 386        // where T : UnityEngine.Object, can not add constraint
 387        sealed class WaitUntilValueChangedUnityObjectPromise<T, U> : IUniTaskSource<U>, IPlayerLoopItem, ITaskPoolNode<W
 388        {
 389            static TaskPool<WaitUntilValueChangedUnityObjectPromise<T, U>> pool;
 390            WaitUntilValueChangedUnityObjectPromise<T, U> nextNode;
 391            public ref WaitUntilValueChangedUnityObjectPromise<T, U> NextNode => ref nextNode;
 392
 393            static WaitUntilValueChangedUnityObjectPromise()
 394            {
 395                TaskPool.RegisterSizeGetter(typeof(WaitUntilValueChangedUnityObjectPromise<T, U>), () => pool.Size);
 396            }
 397
 398            T target;
 399            UnityEngine.Object targetAsUnityObject;
 400            U currentValue;
 401            Func<T, U> monitorFunction;
 402            IEqualityComparer<U> equalityComparer;
 403            CancellationToken cancellationToken;
 404            CancellationTokenRegistration cancellationTokenRegistration;
 405            bool cancelImmediately;
 406
 407            UniTaskCompletionSourceCore<U> core;
 408
 409            WaitUntilValueChangedUnityObjectPromise()
 410            {
 411            }
 412
 413            public static IUniTaskSource<U> Create(T target, Func<T, U> monitorFunction, IEqualityComparer<U> equalityCo
 414            {
 415                if (cancellationToken.IsCancellationRequested)
 416                {
 417                    return AutoResetUniTaskCompletionSource<U>.CreateFromCanceled(cancellationToken, out token);
 418                }
 419
 420                if (!pool.TryPop(out var result))
 421                {
 422                    result = new WaitUntilValueChangedUnityObjectPromise<T, U>();
 423                }
 424
 425                result.target = target;
 426                result.targetAsUnityObject = target as UnityEngine.Object;
 427                result.monitorFunction = monitorFunction;
 428                result.currentValue = monitorFunction(target);
 429                result.equalityComparer = equalityComparer ?? UnityEqualityComparer.GetDefault<U>();
 430                result.cancellationToken = cancellationToken;
 431                result.cancelImmediately = cancelImmediately;
 432
 433                if (cancelImmediately && cancellationToken.CanBeCanceled)
 434                {
 435                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 436                    {
 437                        var promise = (WaitUntilValueChangedUnityObjectPromise<T, U>)state;
 438                        promise.core.TrySetCanceled(promise.cancellationToken);
 439                    }, result);
 440                }
 441
 442                TaskTracker.TrackActiveTask(result, 3);
 443
 444                PlayerLoopHelper.AddAction(timing, result);
 445
 446                token = result.core.Version;
 447                return result;
 448            }
 449
 450            public U GetResult(short token)
 451            {
 452                try
 453                {
 454                    return core.GetResult(token);
 455                }
 456                finally
 457                {
 458                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 459                    {
 460                        TryReturn();
 461                    }
 462                }
 463            }
 464
 465            void IUniTaskSource.GetResult(short token)
 466            {
 467                GetResult(token);
 468            }
 469
 470            public UniTaskStatus GetStatus(short token)
 471            {
 472                return core.GetStatus(token);
 473            }
 474
 475            public UniTaskStatus UnsafeGetStatus()
 476            {
 477                return core.UnsafeGetStatus();
 478            }
 479
 480            public void OnCompleted(Action<object> continuation, object state, short token)
 481            {
 482                core.OnCompleted(continuation, state, token);
 483            }
 484
 485            public bool MoveNext()
 486            {
 487                if (cancellationToken.IsCancellationRequested || targetAsUnityObject == null) // destroyed = cancel.
 488                {
 489                    core.TrySetCanceled(cancellationToken);
 490                    return false;
 491                }
 492
 493                U nextValue = default(U);
 494                try
 495                {
 496                    nextValue = monitorFunction(target);
 497                    if (equalityComparer.Equals(currentValue, nextValue))
 498                    {
 499                        return true;
 500                    }
 501                }
 502                catch (Exception ex)
 503                {
 504                    core.TrySetException(ex);
 505                    return false;
 506                }
 507
 508                core.TrySetResult(nextValue);
 509                return false;
 510            }
 511
 512            bool TryReturn()
 513            {
 514                TaskTracker.RemoveTracking(this);
 515                core.Reset();
 516                target = default;
 517                currentValue = default;
 518                monitorFunction = default;
 519                equalityComparer = default;
 520                cancellationToken = default;
 521                cancellationTokenRegistration.Dispose();
 522                cancelImmediately = default;
 523                return pool.TryPush(this);
 524            }
 525        }
 526
 527        sealed class WaitUntilValueChangedStandardObjectPromise<T, U> : IUniTaskSource<U>, IPlayerLoopItem, ITaskPoolNod
 528            where T : class
 529        {
 530            static TaskPool<WaitUntilValueChangedStandardObjectPromise<T, U>> pool;
 531            WaitUntilValueChangedStandardObjectPromise<T, U> nextNode;
 532            public ref WaitUntilValueChangedStandardObjectPromise<T, U> NextNode => ref nextNode;
 533
 534            static WaitUntilValueChangedStandardObjectPromise()
 535            {
 536                TaskPool.RegisterSizeGetter(typeof(WaitUntilValueChangedStandardObjectPromise<T, U>), () => pool.Size);
 537            }
 538
 539            WeakReference<T> target;
 540            U currentValue;
 541            Func<T, U> monitorFunction;
 542            IEqualityComparer<U> equalityComparer;
 543            CancellationToken cancellationToken;
 544            CancellationTokenRegistration cancellationTokenRegistration;
 545            bool cancelImmediately;
 546
 547            UniTaskCompletionSourceCore<U> core;
 548
 549            WaitUntilValueChangedStandardObjectPromise()
 550            {
 551            }
 552
 553            public static IUniTaskSource<U> Create(T target, Func<T, U> monitorFunction, IEqualityComparer<U> equalityCo
 554            {
 555                if (cancellationToken.IsCancellationRequested)
 556                {
 557                    return AutoResetUniTaskCompletionSource<U>.CreateFromCanceled(cancellationToken, out token);
 558                }
 559
 560                if (!pool.TryPop(out var result))
 561                {
 562                    result = new WaitUntilValueChangedStandardObjectPromise<T, U>();
 563                }
 564
 565                result.target = new WeakReference<T>(target, false); // wrap in WeakReference.
 566                result.monitorFunction = monitorFunction;
 567                result.currentValue = monitorFunction(target);
 568                result.equalityComparer = equalityComparer ?? UnityEqualityComparer.GetDefault<U>();
 569                result.cancellationToken = cancellationToken;
 570                result.cancelImmediately = cancelImmediately;
 571
 572                if (cancelImmediately && cancellationToken.CanBeCanceled)
 573                {
 574                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(stat
 575                    {
 576                        var promise = (WaitUntilValueChangedStandardObjectPromise<T, U>)state;
 577                        promise.core.TrySetCanceled(promise.cancellationToken);
 578                    }, result);
 579                }
 580
 581                TaskTracker.TrackActiveTask(result, 3);
 582
 583                PlayerLoopHelper.AddAction(timing, result);
 584
 585                token = result.core.Version;
 586                return result;
 587            }
 588
 589            public U GetResult(short token)
 590            {
 591                try
 592                {
 593                    return core.GetResult(token);
 594                }
 595                finally
 596                {
 597                    if (!(cancelImmediately && cancellationToken.IsCancellationRequested))
 598                    {
 599                        TryReturn();
 600                    }
 601                }
 602            }
 603
 604            void IUniTaskSource.GetResult(short token)
 605            {
 606                GetResult(token);
 607            }
 608
 609            public UniTaskStatus GetStatus(short token)
 610            {
 611                return core.GetStatus(token);
 612            }
 613
 614            public UniTaskStatus UnsafeGetStatus()
 615            {
 616                return core.UnsafeGetStatus();
 617            }
 618
 619            public void OnCompleted(Action<object> continuation, object state, short token)
 620            {
 621                core.OnCompleted(continuation, state, token);
 622            }
 623
 624            public bool MoveNext()
 625            {
 626                if (cancellationToken.IsCancellationRequested || !target.TryGetTarget(out var t)) // doesn't find = canc
 627                {
 628                    core.TrySetCanceled(cancellationToken);
 629                    return false;
 630                }
 631
 632                U nextValue = default(U);
 633                try
 634                {
 635                    nextValue = monitorFunction(t);
 636                    if (equalityComparer.Equals(currentValue, nextValue))
 637                    {
 638                        return true;
 639                    }
 640                }
 641                catch (Exception ex)
 642                {
 643                    core.TrySetException(ex);
 644                    return false;
 645                }
 646
 647                core.TrySetResult(nextValue);
 648                return false;
 649            }
 650
 651            bool TryReturn()
 652            {
 653                TaskTracker.RemoveTracking(this);
 654                core.Reset();
 655                target = default;
 656                currentValue = default;
 657                monitorFunction = default;
 658                equalityComparer = default;
 659                cancellationToken = default;
 660                cancellationTokenRegistration.Dispose();
 661                cancelImmediately = default;
 662                return pool.TryPush(this);
 663            }
 664        }
 665    }
 666}

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAll.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Threading;
 6using Cysharp.Threading.Tasks.Internal;
 7
 8namespace Cysharp.Threading.Tasks
 9{
 10    public partial struct UniTask
 11    {
 12        public static UniTask<T[]> WhenAll<T>(params UniTask<T>[] tasks)
 013        {
 014            if (tasks.Length == 0)
 015            {
 016                return UniTask.FromResult(Array.Empty<T>());
 17            }
 18
 019            return new UniTask<T[]>(new WhenAllPromise<T>(tasks, tasks.Length), 0);
 020        }
 21
 22        public static UniTask<T[]> WhenAll<T>(IEnumerable<UniTask<T>> tasks)
 023        {
 024            using (var span = ArrayPoolUtil.Materialize(tasks))
 025            {
 026                var promise = new WhenAllPromise<T>(span.Array, span.Length); // consumed array in constructor.
 027                return new UniTask<T[]>(promise, 0);
 28            }
 029        }
 30
 31        public static UniTask WhenAll(params UniTask[] tasks)
 032        {
 033            if (tasks.Length == 0)
 034            {
 035                return UniTask.CompletedTask;
 36            }
 37
 038            return new UniTask(new WhenAllPromise(tasks, tasks.Length), 0);
 039        }
 40
 41        public static UniTask WhenAll(IEnumerable<UniTask> tasks)
 042        {
 043            using (var span = ArrayPoolUtil.Materialize(tasks))
 044            {
 045                var promise = new WhenAllPromise(span.Array, span.Length); // consumed array in constructor.
 046                return new UniTask(promise, 0);
 47            }
 048        }
 49
 50        sealed class WhenAllPromise<T> : IUniTaskSource<T[]>
 51        {
 52            T[] result;
 53            int completeCount;
 54            UniTaskCompletionSourceCore<T[]> core; // don't reset(called after GetResult, will invoke TrySetException.)
 55
 56            public WhenAllPromise(UniTask<T>[] tasks, int tasksLength)
 57            {
 58                TaskTracker.TrackActiveTask(this, 3);
 59
 60                this.completeCount = 0;
 61
 62                if (tasksLength == 0)
 63                {
 64                    this.result = Array.Empty<T>();
 65                    core.TrySetResult(result);
 66                    return;
 67                }
 68
 69                this.result = new T[tasksLength];
 70
 71                for (int i = 0; i < tasksLength; i++)
 72                {
 73                    UniTask<T>.Awaiter awaiter;
 74                    try
 75                    {
 76                        awaiter = tasks[i].GetAwaiter();
 77                    }
 78                    catch (Exception ex)
 79                    {
 80                        core.TrySetException(ex);
 81                        continue;
 82                    }
 83
 84                    if (awaiter.IsCompleted)
 85                    {
 86                        TryInvokeContinuation(this, awaiter, i);
 87                    }
 88                    else
 89                    {
 90                        awaiter.SourceOnCompleted(state =>
 91                        {
 92                            using (var t = (StateTuple<WhenAllPromise<T>, UniTask<T>.Awaiter, int>)state)
 93                            {
 94                                TryInvokeContinuation(t.Item1, t.Item2, t.Item3);
 95                            }
 96                        }, StateTuple.Create(this, awaiter, i));
 97                    }
 98                }
 99            }
 100
 101            static void TryInvokeContinuation(WhenAllPromise<T> self, in UniTask<T>.Awaiter awaiter, int i)
 102            {
 103                try
 104                {
 105                    self.result[i] = awaiter.GetResult();
 106                }
 107                catch (Exception ex)
 108                {
 109                    self.core.TrySetException(ex);
 110                    return;
 111                }
 112
 113                if (Interlocked.Increment(ref self.completeCount) == self.result.Length)
 114                {
 115                    self.core.TrySetResult(self.result);
 116                }
 117            }
 118
 119            public T[] GetResult(short token)
 120            {
 121                TaskTracker.RemoveTracking(this);
 122                GC.SuppressFinalize(this);
 123                return core.GetResult(token);
 124            }
 125
 126            void IUniTaskSource.GetResult(short token)
 127            {
 128                GetResult(token);
 129            }
 130
 131            public UniTaskStatus GetStatus(short token)
 132            {
 133                return core.GetStatus(token);
 134            }
 135
 136            public UniTaskStatus UnsafeGetStatus()
 137            {
 138                return core.UnsafeGetStatus();
 139            }
 140
 141            public void OnCompleted(Action<object> continuation, object state, short token)
 142            {
 143                core.OnCompleted(continuation, state, token);
 144            }
 145        }
 146
 147        sealed class WhenAllPromise : IUniTaskSource
 148        {
 149            int completeCount;
 150            int tasksLength;
 151            UniTaskCompletionSourceCore<AsyncUnit> core; // don't reset(called after GetResult, will invoke TrySetExcept
 152
 0153            public WhenAllPromise(UniTask[] tasks, int tasksLength)
 0154            {
 0155                TaskTracker.TrackActiveTask(this, 3);
 156
 0157                this.tasksLength = tasksLength;
 0158                this.completeCount = 0;
 159
 0160                if (tasksLength == 0)
 0161                {
 0162                    core.TrySetResult(AsyncUnit.Default);
 0163                    return;
 164                }
 165
 0166                for (int i = 0; i < tasksLength; i++)
 0167                {
 168                    UniTask.Awaiter awaiter;
 169                    try
 0170                    {
 0171                        awaiter = tasks[i].GetAwaiter();
 0172                    }
 0173                    catch (Exception ex)
 0174                    {
 0175                        core.TrySetException(ex);
 0176                        continue;
 177                    }
 178
 0179                    if (awaiter.IsCompleted)
 0180                    {
 0181                        TryInvokeContinuation(this, awaiter);
 0182                    }
 183                    else
 0184                    {
 0185                        awaiter.SourceOnCompleted(state =>
 0186                        {
 0187                            using (var t = (StateTuple<WhenAllPromise, UniTask.Awaiter>)state)
 0188                            {
 0189                                TryInvokeContinuation(t.Item1, t.Item2);
 0190                            }
 0191                        }, StateTuple.Create(this, awaiter));
 0192                    }
 0193                }
 0194            }
 195
 196            static void TryInvokeContinuation(WhenAllPromise self, in UniTask.Awaiter awaiter)
 0197            {
 198                try
 0199                {
 0200                    awaiter.GetResult();
 0201                }
 0202                catch (Exception ex)
 0203                {
 0204                    self.core.TrySetException(ex);
 0205                    return;
 206                }
 207
 0208                if (Interlocked.Increment(ref self.completeCount) == self.tasksLength)
 0209                {
 0210                    self.core.TrySetResult(AsyncUnit.Default);
 0211                }
 0212            }
 213
 214            public void GetResult(short token)
 0215            {
 0216                TaskTracker.RemoveTracking(this);
 0217                GC.SuppressFinalize(this);
 0218                core.GetResult(token);
 0219            }
 220
 221            public UniTaskStatus GetStatus(short token)
 0222            {
 0223                return core.GetStatus(token);
 0224            }
 225
 226            public UniTaskStatus UnsafeGetStatus()
 0227            {
 0228                return core.UnsafeGetStatus();
 0229            }
 230
 231            public void OnCompleted(Action<object> continuation, object state, short token)
 0232            {
 0233                core.OnCompleted(continuation, state, token);
 0234            }
 235        }
 236    }
 237}

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAll.Generated.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2using System;
 3using System.Runtime.CompilerServices;
 4using System.Runtime.ExceptionServices;
 5using System.Threading;
 6using Cysharp.Threading.Tasks.Internal;
 7
 8namespace Cysharp.Threading.Tasks
 9{
 10    public partial struct UniTask
 11    {
 12
 13        public static UniTask<(T1, T2)> WhenAll<T1, T2>(UniTask<T1> task1, UniTask<T2> task2)
 014        {
 015            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully())
 016            {
 017                return new UniTask<(T1, T2)>((task1.GetAwaiter().GetResult(), task2.GetAwaiter().GetResult()));
 18            }
 19
 020            return new UniTask<(T1, T2)>(new WhenAllPromise<T1, T2>(task1, task2), 0);
 021        }
 22
 23        sealed class WhenAllPromise<T1, T2> : IUniTaskSource<(T1, T2)>
 24        {
 25            T1 t1 = default;
 26            T2 t2 = default;
 27            int completedCount;
 28            UniTaskCompletionSourceCore<(T1, T2)> core;
 29
 30            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2)
 31            {
 32                TaskTracker.TrackActiveTask(this, 3);
 33
 34                this.completedCount = 0;
 35                {
 36                    var awaiter = task1.GetAwaiter();
 37                    if (awaiter.IsCompleted)
 38                    {
 39                        TryInvokeContinuationT1(this, awaiter);
 40                    }
 41                    else
 42                    {
 43                        awaiter.SourceOnCompleted(state =>
 44                        {
 45                            using (var t = (StateTuple<WhenAllPromise<T1, T2>, UniTask<T1>.Awaiter>)state)
 46                            {
 47                                TryInvokeContinuationT1(t.Item1, t.Item2);
 48                            }
 49                        }, StateTuple.Create(this, awaiter));
 50                    }
 51                }
 52                {
 53                    var awaiter = task2.GetAwaiter();
 54                    if (awaiter.IsCompleted)
 55                    {
 56                        TryInvokeContinuationT2(this, awaiter);
 57                    }
 58                    else
 59                    {
 60                        awaiter.SourceOnCompleted(state =>
 61                        {
 62                            using (var t = (StateTuple<WhenAllPromise<T1, T2>, UniTask<T2>.Awaiter>)state)
 63                            {
 64                                TryInvokeContinuationT2(t.Item1, t.Item2);
 65                            }
 66                        }, StateTuple.Create(this, awaiter));
 67                    }
 68                }
 69            }
 70
 71            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2> self, in UniTask<T1>.Awaiter awaiter)
 72            {
 73                try
 74                {
 75                    self.t1 = awaiter.GetResult();
 76                }
 77                catch (Exception ex)
 78                {
 79                    self.core.TrySetException(ex);
 80                    return;
 81                }
 82
 83                if (Interlocked.Increment(ref self.completedCount) == 2)
 84                {
 85                    self.core.TrySetResult((self.t1, self.t2));
 86                }
 87            }
 88
 89            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2> self, in UniTask<T2>.Awaiter awaiter)
 90            {
 91                try
 92                {
 93                    self.t2 = awaiter.GetResult();
 94                }
 95                catch (Exception ex)
 96                {
 97                    self.core.TrySetException(ex);
 98                    return;
 99                }
 100
 101                if (Interlocked.Increment(ref self.completedCount) == 2)
 102                {
 103                    self.core.TrySetResult((self.t1, self.t2));
 104                }
 105            }
 106
 107
 108            public (T1, T2) GetResult(short token)
 109            {
 110                TaskTracker.RemoveTracking(this);
 111                GC.SuppressFinalize(this);
 112                return core.GetResult(token);
 113            }
 114
 115            void IUniTaskSource.GetResult(short token)
 116            {
 117                GetResult(token);
 118            }
 119
 120            public UniTaskStatus GetStatus(short token)
 121            {
 122                return core.GetStatus(token);
 123            }
 124
 125            public UniTaskStatus UnsafeGetStatus()
 126            {
 127                return core.UnsafeGetStatus();
 128            }
 129
 130            public void OnCompleted(Action<object> continuation, object state, short token)
 131            {
 132                core.OnCompleted(continuation, state, token);
 133            }
 134        }
 135
 136        public static UniTask<(T1, T2, T3)> WhenAll<T1, T2, T3>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3)
 0137        {
 0138            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 0139            {
 0140                return new UniTask<(T1, T2, T3)>((task1.GetAwaiter().GetResult(), task2.GetAwaiter().GetResult(), task3.
 141            }
 142
 0143            return new UniTask<(T1, T2, T3)>(new WhenAllPromise<T1, T2, T3>(task1, task2, task3), 0);
 0144        }
 145
 146        sealed class WhenAllPromise<T1, T2, T3> : IUniTaskSource<(T1, T2, T3)>
 147        {
 148            T1 t1 = default;
 149            T2 t2 = default;
 150            T3 t3 = default;
 151            int completedCount;
 152            UniTaskCompletionSourceCore<(T1, T2, T3)> core;
 153
 154            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3)
 155            {
 156                TaskTracker.TrackActiveTask(this, 3);
 157
 158                this.completedCount = 0;
 159                {
 160                    var awaiter = task1.GetAwaiter();
 161                    if (awaiter.IsCompleted)
 162                    {
 163                        TryInvokeContinuationT1(this, awaiter);
 164                    }
 165                    else
 166                    {
 167                        awaiter.SourceOnCompleted(state =>
 168                        {
 169                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3>, UniTask<T1>.Awaiter>)state)
 170                            {
 171                                TryInvokeContinuationT1(t.Item1, t.Item2);
 172                            }
 173                        }, StateTuple.Create(this, awaiter));
 174                    }
 175                }
 176                {
 177                    var awaiter = task2.GetAwaiter();
 178                    if (awaiter.IsCompleted)
 179                    {
 180                        TryInvokeContinuationT2(this, awaiter);
 181                    }
 182                    else
 183                    {
 184                        awaiter.SourceOnCompleted(state =>
 185                        {
 186                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3>, UniTask<T2>.Awaiter>)state)
 187                            {
 188                                TryInvokeContinuationT2(t.Item1, t.Item2);
 189                            }
 190                        }, StateTuple.Create(this, awaiter));
 191                    }
 192                }
 193                {
 194                    var awaiter = task3.GetAwaiter();
 195                    if (awaiter.IsCompleted)
 196                    {
 197                        TryInvokeContinuationT3(this, awaiter);
 198                    }
 199                    else
 200                    {
 201                        awaiter.SourceOnCompleted(state =>
 202                        {
 203                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3>, UniTask<T3>.Awaiter>)state)
 204                            {
 205                                TryInvokeContinuationT3(t.Item1, t.Item2);
 206                            }
 207                        }, StateTuple.Create(this, awaiter));
 208                    }
 209                }
 210            }
 211
 212            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3> self, in UniTask<T1>.Awaiter awaiter)
 213            {
 214                try
 215                {
 216                    self.t1 = awaiter.GetResult();
 217                }
 218                catch (Exception ex)
 219                {
 220                    self.core.TrySetException(ex);
 221                    return;
 222                }
 223
 224                if (Interlocked.Increment(ref self.completedCount) == 3)
 225                {
 226                    self.core.TrySetResult((self.t1, self.t2, self.t3));
 227                }
 228            }
 229
 230            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3> self, in UniTask<T2>.Awaiter awaiter)
 231            {
 232                try
 233                {
 234                    self.t2 = awaiter.GetResult();
 235                }
 236                catch (Exception ex)
 237                {
 238                    self.core.TrySetException(ex);
 239                    return;
 240                }
 241
 242                if (Interlocked.Increment(ref self.completedCount) == 3)
 243                {
 244                    self.core.TrySetResult((self.t1, self.t2, self.t3));
 245                }
 246            }
 247
 248            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3> self, in UniTask<T3>.Awaiter awaiter)
 249            {
 250                try
 251                {
 252                    self.t3 = awaiter.GetResult();
 253                }
 254                catch (Exception ex)
 255                {
 256                    self.core.TrySetException(ex);
 257                    return;
 258                }
 259
 260                if (Interlocked.Increment(ref self.completedCount) == 3)
 261                {
 262                    self.core.TrySetResult((self.t1, self.t2, self.t3));
 263                }
 264            }
 265
 266
 267            public (T1, T2, T3) GetResult(short token)
 268            {
 269                TaskTracker.RemoveTracking(this);
 270                GC.SuppressFinalize(this);
 271                return core.GetResult(token);
 272            }
 273
 274            void IUniTaskSource.GetResult(short token)
 275            {
 276                GetResult(token);
 277            }
 278
 279            public UniTaskStatus GetStatus(short token)
 280            {
 281                return core.GetStatus(token);
 282            }
 283
 284            public UniTaskStatus UnsafeGetStatus()
 285            {
 286                return core.UnsafeGetStatus();
 287            }
 288
 289            public void OnCompleted(Action<object> continuation, object state, short token)
 290            {
 291                core.OnCompleted(continuation, state, token);
 292            }
 293        }
 294
 295        public static UniTask<(T1, T2, T3, T4)> WhenAll<T1, T2, T3, T4>(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3
 0296        {
 0297            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 0298            {
 0299                return new UniTask<(T1, T2, T3, T4)>((task1.GetAwaiter().GetResult(), task2.GetAwaiter().GetResult(), ta
 300            }
 301
 0302            return new UniTask<(T1, T2, T3, T4)>(new WhenAllPromise<T1, T2, T3, T4>(task1, task2, task3, task4), 0);
 0303        }
 304
 305        sealed class WhenAllPromise<T1, T2, T3, T4> : IUniTaskSource<(T1, T2, T3, T4)>
 306        {
 307            T1 t1 = default;
 308            T2 t2 = default;
 309            T3 t3 = default;
 310            T4 t4 = default;
 311            int completedCount;
 312            UniTaskCompletionSourceCore<(T1, T2, T3, T4)> core;
 313
 314            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4)
 315            {
 316                TaskTracker.TrackActiveTask(this, 3);
 317
 318                this.completedCount = 0;
 319                {
 320                    var awaiter = task1.GetAwaiter();
 321                    if (awaiter.IsCompleted)
 322                    {
 323                        TryInvokeContinuationT1(this, awaiter);
 324                    }
 325                    else
 326                    {
 327                        awaiter.SourceOnCompleted(state =>
 328                        {
 329                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4>, UniTask<T1>.Awaiter>)state)
 330                            {
 331                                TryInvokeContinuationT1(t.Item1, t.Item2);
 332                            }
 333                        }, StateTuple.Create(this, awaiter));
 334                    }
 335                }
 336                {
 337                    var awaiter = task2.GetAwaiter();
 338                    if (awaiter.IsCompleted)
 339                    {
 340                        TryInvokeContinuationT2(this, awaiter);
 341                    }
 342                    else
 343                    {
 344                        awaiter.SourceOnCompleted(state =>
 345                        {
 346                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4>, UniTask<T2>.Awaiter>)state)
 347                            {
 348                                TryInvokeContinuationT2(t.Item1, t.Item2);
 349                            }
 350                        }, StateTuple.Create(this, awaiter));
 351                    }
 352                }
 353                {
 354                    var awaiter = task3.GetAwaiter();
 355                    if (awaiter.IsCompleted)
 356                    {
 357                        TryInvokeContinuationT3(this, awaiter);
 358                    }
 359                    else
 360                    {
 361                        awaiter.SourceOnCompleted(state =>
 362                        {
 363                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4>, UniTask<T3>.Awaiter>)state)
 364                            {
 365                                TryInvokeContinuationT3(t.Item1, t.Item2);
 366                            }
 367                        }, StateTuple.Create(this, awaiter));
 368                    }
 369                }
 370                {
 371                    var awaiter = task4.GetAwaiter();
 372                    if (awaiter.IsCompleted)
 373                    {
 374                        TryInvokeContinuationT4(this, awaiter);
 375                    }
 376                    else
 377                    {
 378                        awaiter.SourceOnCompleted(state =>
 379                        {
 380                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4>, UniTask<T4>.Awaiter>)state)
 381                            {
 382                                TryInvokeContinuationT4(t.Item1, t.Item2);
 383                            }
 384                        }, StateTuple.Create(this, awaiter));
 385                    }
 386                }
 387            }
 388
 389            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4> self, in UniTask<T1>.Awaiter awaiter)
 390            {
 391                try
 392                {
 393                    self.t1 = awaiter.GetResult();
 394                }
 395                catch (Exception ex)
 396                {
 397                    self.core.TrySetException(ex);
 398                    return;
 399                }
 400
 401                if (Interlocked.Increment(ref self.completedCount) == 4)
 402                {
 403                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4));
 404                }
 405            }
 406
 407            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4> self, in UniTask<T2>.Awaiter awaiter)
 408            {
 409                try
 410                {
 411                    self.t2 = awaiter.GetResult();
 412                }
 413                catch (Exception ex)
 414                {
 415                    self.core.TrySetException(ex);
 416                    return;
 417                }
 418
 419                if (Interlocked.Increment(ref self.completedCount) == 4)
 420                {
 421                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4));
 422                }
 423            }
 424
 425            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4> self, in UniTask<T3>.Awaiter awaiter)
 426            {
 427                try
 428                {
 429                    self.t3 = awaiter.GetResult();
 430                }
 431                catch (Exception ex)
 432                {
 433                    self.core.TrySetException(ex);
 434                    return;
 435                }
 436
 437                if (Interlocked.Increment(ref self.completedCount) == 4)
 438                {
 439                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4));
 440                }
 441            }
 442
 443            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4> self, in UniTask<T4>.Awaiter awaiter)
 444            {
 445                try
 446                {
 447                    self.t4 = awaiter.GetResult();
 448                }
 449                catch (Exception ex)
 450                {
 451                    self.core.TrySetException(ex);
 452                    return;
 453                }
 454
 455                if (Interlocked.Increment(ref self.completedCount) == 4)
 456                {
 457                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4));
 458                }
 459            }
 460
 461
 462            public (T1, T2, T3, T4) GetResult(short token)
 463            {
 464                TaskTracker.RemoveTracking(this);
 465                GC.SuppressFinalize(this);
 466                return core.GetResult(token);
 467            }
 468
 469            void IUniTaskSource.GetResult(short token)
 470            {
 471                GetResult(token);
 472            }
 473
 474            public UniTaskStatus GetStatus(short token)
 475            {
 476                return core.GetStatus(token);
 477            }
 478
 479            public UniTaskStatus UnsafeGetStatus()
 480            {
 481                return core.UnsafeGetStatus();
 482            }
 483
 484            public void OnCompleted(Action<object> continuation, object state, short token)
 485            {
 486                core.OnCompleted(continuation, state, token);
 487            }
 488        }
 489
 490        public static UniTask<(T1, T2, T3, T4, T5)> WhenAll<T1, T2, T3, T4, T5>(UniTask<T1> task1, UniTask<T2> task2, Un
 0491        {
 0492            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 0493            {
 0494                return new UniTask<(T1, T2, T3, T4, T5)>((task1.GetAwaiter().GetResult(), task2.GetAwaiter().GetResult()
 495            }
 496
 0497            return new UniTask<(T1, T2, T3, T4, T5)>(new WhenAllPromise<T1, T2, T3, T4, T5>(task1, task2, task3, task4, 
 0498        }
 499
 500        sealed class WhenAllPromise<T1, T2, T3, T4, T5> : IUniTaskSource<(T1, T2, T3, T4, T5)>
 501        {
 502            T1 t1 = default;
 503            T2 t2 = default;
 504            T3 t3 = default;
 505            T4 t4 = default;
 506            T5 t5 = default;
 507            int completedCount;
 508            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5)> core;
 509
 510            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 511            {
 512                TaskTracker.TrackActiveTask(this, 3);
 513
 514                this.completedCount = 0;
 515                {
 516                    var awaiter = task1.GetAwaiter();
 517                    if (awaiter.IsCompleted)
 518                    {
 519                        TryInvokeContinuationT1(this, awaiter);
 520                    }
 521                    else
 522                    {
 523                        awaiter.SourceOnCompleted(state =>
 524                        {
 525                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5>, UniTask<T1>.Awaiter>)state)
 526                            {
 527                                TryInvokeContinuationT1(t.Item1, t.Item2);
 528                            }
 529                        }, StateTuple.Create(this, awaiter));
 530                    }
 531                }
 532                {
 533                    var awaiter = task2.GetAwaiter();
 534                    if (awaiter.IsCompleted)
 535                    {
 536                        TryInvokeContinuationT2(this, awaiter);
 537                    }
 538                    else
 539                    {
 540                        awaiter.SourceOnCompleted(state =>
 541                        {
 542                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5>, UniTask<T2>.Awaiter>)state)
 543                            {
 544                                TryInvokeContinuationT2(t.Item1, t.Item2);
 545                            }
 546                        }, StateTuple.Create(this, awaiter));
 547                    }
 548                }
 549                {
 550                    var awaiter = task3.GetAwaiter();
 551                    if (awaiter.IsCompleted)
 552                    {
 553                        TryInvokeContinuationT3(this, awaiter);
 554                    }
 555                    else
 556                    {
 557                        awaiter.SourceOnCompleted(state =>
 558                        {
 559                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5>, UniTask<T3>.Awaiter>)state)
 560                            {
 561                                TryInvokeContinuationT3(t.Item1, t.Item2);
 562                            }
 563                        }, StateTuple.Create(this, awaiter));
 564                    }
 565                }
 566                {
 567                    var awaiter = task4.GetAwaiter();
 568                    if (awaiter.IsCompleted)
 569                    {
 570                        TryInvokeContinuationT4(this, awaiter);
 571                    }
 572                    else
 573                    {
 574                        awaiter.SourceOnCompleted(state =>
 575                        {
 576                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5>, UniTask<T4>.Awaiter>)state)
 577                            {
 578                                TryInvokeContinuationT4(t.Item1, t.Item2);
 579                            }
 580                        }, StateTuple.Create(this, awaiter));
 581                    }
 582                }
 583                {
 584                    var awaiter = task5.GetAwaiter();
 585                    if (awaiter.IsCompleted)
 586                    {
 587                        TryInvokeContinuationT5(this, awaiter);
 588                    }
 589                    else
 590                    {
 591                        awaiter.SourceOnCompleted(state =>
 592                        {
 593                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5>, UniTask<T5>.Awaiter>)state)
 594                            {
 595                                TryInvokeContinuationT5(t.Item1, t.Item2);
 596                            }
 597                        }, StateTuple.Create(this, awaiter));
 598                    }
 599                }
 600            }
 601
 602            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5> self, in UniTask<T1>.Awaiter awaiter)
 603            {
 604                try
 605                {
 606                    self.t1 = awaiter.GetResult();
 607                }
 608                catch (Exception ex)
 609                {
 610                    self.core.TrySetException(ex);
 611                    return;
 612                }
 613
 614                if (Interlocked.Increment(ref self.completedCount) == 5)
 615                {
 616                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5));
 617                }
 618            }
 619
 620            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5> self, in UniTask<T2>.Awaiter awaiter)
 621            {
 622                try
 623                {
 624                    self.t2 = awaiter.GetResult();
 625                }
 626                catch (Exception ex)
 627                {
 628                    self.core.TrySetException(ex);
 629                    return;
 630                }
 631
 632                if (Interlocked.Increment(ref self.completedCount) == 5)
 633                {
 634                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5));
 635                }
 636            }
 637
 638            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5> self, in UniTask<T3>.Awaiter awaiter)
 639            {
 640                try
 641                {
 642                    self.t3 = awaiter.GetResult();
 643                }
 644                catch (Exception ex)
 645                {
 646                    self.core.TrySetException(ex);
 647                    return;
 648                }
 649
 650                if (Interlocked.Increment(ref self.completedCount) == 5)
 651                {
 652                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5));
 653                }
 654            }
 655
 656            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5> self, in UniTask<T4>.Awaiter awaiter)
 657            {
 658                try
 659                {
 660                    self.t4 = awaiter.GetResult();
 661                }
 662                catch (Exception ex)
 663                {
 664                    self.core.TrySetException(ex);
 665                    return;
 666                }
 667
 668                if (Interlocked.Increment(ref self.completedCount) == 5)
 669                {
 670                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5));
 671                }
 672            }
 673
 674            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5> self, in UniTask<T5>.Awaiter awaiter)
 675            {
 676                try
 677                {
 678                    self.t5 = awaiter.GetResult();
 679                }
 680                catch (Exception ex)
 681                {
 682                    self.core.TrySetException(ex);
 683                    return;
 684                }
 685
 686                if (Interlocked.Increment(ref self.completedCount) == 5)
 687                {
 688                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5));
 689                }
 690            }
 691
 692
 693            public (T1, T2, T3, T4, T5) GetResult(short token)
 694            {
 695                TaskTracker.RemoveTracking(this);
 696                GC.SuppressFinalize(this);
 697                return core.GetResult(token);
 698            }
 699
 700            void IUniTaskSource.GetResult(short token)
 701            {
 702                GetResult(token);
 703            }
 704
 705            public UniTaskStatus GetStatus(short token)
 706            {
 707                return core.GetStatus(token);
 708            }
 709
 710            public UniTaskStatus UnsafeGetStatus()
 711            {
 712                return core.UnsafeGetStatus();
 713            }
 714
 715            public void OnCompleted(Action<object> continuation, object state, short token)
 716            {
 717                core.OnCompleted(continuation, state, token);
 718            }
 719        }
 720
 721        public static UniTask<(T1, T2, T3, T4, T5, T6)> WhenAll<T1, T2, T3, T4, T5, T6>(UniTask<T1> task1, UniTask<T2> t
 0722        {
 0723            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 0724            {
 0725                return new UniTask<(T1, T2, T3, T4, T5, T6)>((task1.GetAwaiter().GetResult(), task2.GetAwaiter().GetResu
 726            }
 727
 0728            return new UniTask<(T1, T2, T3, T4, T5, T6)>(new WhenAllPromise<T1, T2, T3, T4, T5, T6>(task1, task2, task3,
 0729        }
 730
 731        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6> : IUniTaskSource<(T1, T2, T3, T4, T5, T6)>
 732        {
 733            T1 t1 = default;
 734            T2 t2 = default;
 735            T3 t3 = default;
 736            T4 t4 = default;
 737            T5 t5 = default;
 738            T6 t6 = default;
 739            int completedCount;
 740            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6)> core;
 741
 742            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 743            {
 744                TaskTracker.TrackActiveTask(this, 3);
 745
 746                this.completedCount = 0;
 747                {
 748                    var awaiter = task1.GetAwaiter();
 749                    if (awaiter.IsCompleted)
 750                    {
 751                        TryInvokeContinuationT1(this, awaiter);
 752                    }
 753                    else
 754                    {
 755                        awaiter.SourceOnCompleted(state =>
 756                        {
 757                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6>, UniTask<T1>.Awaiter>)stat
 758                            {
 759                                TryInvokeContinuationT1(t.Item1, t.Item2);
 760                            }
 761                        }, StateTuple.Create(this, awaiter));
 762                    }
 763                }
 764                {
 765                    var awaiter = task2.GetAwaiter();
 766                    if (awaiter.IsCompleted)
 767                    {
 768                        TryInvokeContinuationT2(this, awaiter);
 769                    }
 770                    else
 771                    {
 772                        awaiter.SourceOnCompleted(state =>
 773                        {
 774                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6>, UniTask<T2>.Awaiter>)stat
 775                            {
 776                                TryInvokeContinuationT2(t.Item1, t.Item2);
 777                            }
 778                        }, StateTuple.Create(this, awaiter));
 779                    }
 780                }
 781                {
 782                    var awaiter = task3.GetAwaiter();
 783                    if (awaiter.IsCompleted)
 784                    {
 785                        TryInvokeContinuationT3(this, awaiter);
 786                    }
 787                    else
 788                    {
 789                        awaiter.SourceOnCompleted(state =>
 790                        {
 791                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6>, UniTask<T3>.Awaiter>)stat
 792                            {
 793                                TryInvokeContinuationT3(t.Item1, t.Item2);
 794                            }
 795                        }, StateTuple.Create(this, awaiter));
 796                    }
 797                }
 798                {
 799                    var awaiter = task4.GetAwaiter();
 800                    if (awaiter.IsCompleted)
 801                    {
 802                        TryInvokeContinuationT4(this, awaiter);
 803                    }
 804                    else
 805                    {
 806                        awaiter.SourceOnCompleted(state =>
 807                        {
 808                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6>, UniTask<T4>.Awaiter>)stat
 809                            {
 810                                TryInvokeContinuationT4(t.Item1, t.Item2);
 811                            }
 812                        }, StateTuple.Create(this, awaiter));
 813                    }
 814                }
 815                {
 816                    var awaiter = task5.GetAwaiter();
 817                    if (awaiter.IsCompleted)
 818                    {
 819                        TryInvokeContinuationT5(this, awaiter);
 820                    }
 821                    else
 822                    {
 823                        awaiter.SourceOnCompleted(state =>
 824                        {
 825                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6>, UniTask<T5>.Awaiter>)stat
 826                            {
 827                                TryInvokeContinuationT5(t.Item1, t.Item2);
 828                            }
 829                        }, StateTuple.Create(this, awaiter));
 830                    }
 831                }
 832                {
 833                    var awaiter = task6.GetAwaiter();
 834                    if (awaiter.IsCompleted)
 835                    {
 836                        TryInvokeContinuationT6(this, awaiter);
 837                    }
 838                    else
 839                    {
 840                        awaiter.SourceOnCompleted(state =>
 841                        {
 842                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6>, UniTask<T6>.Awaiter>)stat
 843                            {
 844                                TryInvokeContinuationT6(t.Item1, t.Item2);
 845                            }
 846                        }, StateTuple.Create(this, awaiter));
 847                    }
 848                }
 849            }
 850
 851            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T1>.Awaiter awai
 852            {
 853                try
 854                {
 855                    self.t1 = awaiter.GetResult();
 856                }
 857                catch (Exception ex)
 858                {
 859                    self.core.TrySetException(ex);
 860                    return;
 861                }
 862
 863                if (Interlocked.Increment(ref self.completedCount) == 6)
 864                {
 865                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6));
 866                }
 867            }
 868
 869            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T2>.Awaiter awai
 870            {
 871                try
 872                {
 873                    self.t2 = awaiter.GetResult();
 874                }
 875                catch (Exception ex)
 876                {
 877                    self.core.TrySetException(ex);
 878                    return;
 879                }
 880
 881                if (Interlocked.Increment(ref self.completedCount) == 6)
 882                {
 883                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6));
 884                }
 885            }
 886
 887            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T3>.Awaiter awai
 888            {
 889                try
 890                {
 891                    self.t3 = awaiter.GetResult();
 892                }
 893                catch (Exception ex)
 894                {
 895                    self.core.TrySetException(ex);
 896                    return;
 897                }
 898
 899                if (Interlocked.Increment(ref self.completedCount) == 6)
 900                {
 901                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6));
 902                }
 903            }
 904
 905            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T4>.Awaiter awai
 906            {
 907                try
 908                {
 909                    self.t4 = awaiter.GetResult();
 910                }
 911                catch (Exception ex)
 912                {
 913                    self.core.TrySetException(ex);
 914                    return;
 915                }
 916
 917                if (Interlocked.Increment(ref self.completedCount) == 6)
 918                {
 919                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6));
 920                }
 921            }
 922
 923            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T5>.Awaiter awai
 924            {
 925                try
 926                {
 927                    self.t5 = awaiter.GetResult();
 928                }
 929                catch (Exception ex)
 930                {
 931                    self.core.TrySetException(ex);
 932                    return;
 933                }
 934
 935                if (Interlocked.Increment(ref self.completedCount) == 6)
 936                {
 937                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6));
 938                }
 939            }
 940
 941            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T6>.Awaiter awai
 942            {
 943                try
 944                {
 945                    self.t6 = awaiter.GetResult();
 946                }
 947                catch (Exception ex)
 948                {
 949                    self.core.TrySetException(ex);
 950                    return;
 951                }
 952
 953                if (Interlocked.Increment(ref self.completedCount) == 6)
 954                {
 955                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6));
 956                }
 957            }
 958
 959
 960            public (T1, T2, T3, T4, T5, T6) GetResult(short token)
 961            {
 962                TaskTracker.RemoveTracking(this);
 963                GC.SuppressFinalize(this);
 964                return core.GetResult(token);
 965            }
 966
 967            void IUniTaskSource.GetResult(short token)
 968            {
 969                GetResult(token);
 970            }
 971
 972            public UniTaskStatus GetStatus(short token)
 973            {
 974                return core.GetStatus(token);
 975            }
 976
 977            public UniTaskStatus UnsafeGetStatus()
 978            {
 979                return core.UnsafeGetStatus();
 980            }
 981
 982            public void OnCompleted(Action<object> continuation, object state, short token)
 983            {
 984                core.OnCompleted(continuation, state, token);
 985            }
 986        }
 987
 988        public static UniTask<(T1, T2, T3, T4, T5, T6, T7)> WhenAll<T1, T2, T3, T4, T5, T6, T7>(UniTask<T1> task1, UniTa
 0989        {
 0990            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 0991            {
 0992                return new UniTask<(T1, T2, T3, T4, T5, T6, T7)>((task1.GetAwaiter().GetResult(), task2.GetAwaiter().Get
 993            }
 994
 0995            return new UniTask<(T1, T2, T3, T4, T5, T6, T7)>(new WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>(task1, task2
 0996        }
 997
 998        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> : IUniTaskSource<(T1, T2, T3, T4, T5, T6, T7)>
 999        {
 1000            T1 t1 = default;
 1001            T2 t2 = default;
 1002            T3 t3 = default;
 1003            T4 t4 = default;
 1004            T5 t5 = default;
 1005            T6 t6 = default;
 1006            T7 t7 = default;
 1007            int completedCount;
 1008            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7)> core;
 1009
 1010            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 1011            {
 1012                TaskTracker.TrackActiveTask(this, 3);
 1013
 1014                this.completedCount = 0;
 1015                {
 1016                    var awaiter = task1.GetAwaiter();
 1017                    if (awaiter.IsCompleted)
 1018                    {
 1019                        TryInvokeContinuationT1(this, awaiter);
 1020                    }
 1021                    else
 1022                    {
 1023                        awaiter.SourceOnCompleted(state =>
 1024                        {
 1025                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T1>.Awaiter>)
 1026                            {
 1027                                TryInvokeContinuationT1(t.Item1, t.Item2);
 1028                            }
 1029                        }, StateTuple.Create(this, awaiter));
 1030                    }
 1031                }
 1032                {
 1033                    var awaiter = task2.GetAwaiter();
 1034                    if (awaiter.IsCompleted)
 1035                    {
 1036                        TryInvokeContinuationT2(this, awaiter);
 1037                    }
 1038                    else
 1039                    {
 1040                        awaiter.SourceOnCompleted(state =>
 1041                        {
 1042                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T2>.Awaiter>)
 1043                            {
 1044                                TryInvokeContinuationT2(t.Item1, t.Item2);
 1045                            }
 1046                        }, StateTuple.Create(this, awaiter));
 1047                    }
 1048                }
 1049                {
 1050                    var awaiter = task3.GetAwaiter();
 1051                    if (awaiter.IsCompleted)
 1052                    {
 1053                        TryInvokeContinuationT3(this, awaiter);
 1054                    }
 1055                    else
 1056                    {
 1057                        awaiter.SourceOnCompleted(state =>
 1058                        {
 1059                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T3>.Awaiter>)
 1060                            {
 1061                                TryInvokeContinuationT3(t.Item1, t.Item2);
 1062                            }
 1063                        }, StateTuple.Create(this, awaiter));
 1064                    }
 1065                }
 1066                {
 1067                    var awaiter = task4.GetAwaiter();
 1068                    if (awaiter.IsCompleted)
 1069                    {
 1070                        TryInvokeContinuationT4(this, awaiter);
 1071                    }
 1072                    else
 1073                    {
 1074                        awaiter.SourceOnCompleted(state =>
 1075                        {
 1076                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T4>.Awaiter>)
 1077                            {
 1078                                TryInvokeContinuationT4(t.Item1, t.Item2);
 1079                            }
 1080                        }, StateTuple.Create(this, awaiter));
 1081                    }
 1082                }
 1083                {
 1084                    var awaiter = task5.GetAwaiter();
 1085                    if (awaiter.IsCompleted)
 1086                    {
 1087                        TryInvokeContinuationT5(this, awaiter);
 1088                    }
 1089                    else
 1090                    {
 1091                        awaiter.SourceOnCompleted(state =>
 1092                        {
 1093                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T5>.Awaiter>)
 1094                            {
 1095                                TryInvokeContinuationT5(t.Item1, t.Item2);
 1096                            }
 1097                        }, StateTuple.Create(this, awaiter));
 1098                    }
 1099                }
 1100                {
 1101                    var awaiter = task6.GetAwaiter();
 1102                    if (awaiter.IsCompleted)
 1103                    {
 1104                        TryInvokeContinuationT6(this, awaiter);
 1105                    }
 1106                    else
 1107                    {
 1108                        awaiter.SourceOnCompleted(state =>
 1109                        {
 1110                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T6>.Awaiter>)
 1111                            {
 1112                                TryInvokeContinuationT6(t.Item1, t.Item2);
 1113                            }
 1114                        }, StateTuple.Create(this, awaiter));
 1115                    }
 1116                }
 1117                {
 1118                    var awaiter = task7.GetAwaiter();
 1119                    if (awaiter.IsCompleted)
 1120                    {
 1121                        TryInvokeContinuationT7(this, awaiter);
 1122                    }
 1123                    else
 1124                    {
 1125                        awaiter.SourceOnCompleted(state =>
 1126                        {
 1127                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T7>.Awaiter>)
 1128                            {
 1129                                TryInvokeContinuationT7(t.Item1, t.Item2);
 1130                            }
 1131                        }, StateTuple.Create(this, awaiter));
 1132                    }
 1133                }
 1134            }
 1135
 1136            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T1>.Awaiter 
 1137            {
 1138                try
 1139                {
 1140                    self.t1 = awaiter.GetResult();
 1141                }
 1142                catch (Exception ex)
 1143                {
 1144                    self.core.TrySetException(ex);
 1145                    return;
 1146                }
 1147
 1148                if (Interlocked.Increment(ref self.completedCount) == 7)
 1149                {
 1150                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7));
 1151                }
 1152            }
 1153
 1154            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T2>.Awaiter 
 1155            {
 1156                try
 1157                {
 1158                    self.t2 = awaiter.GetResult();
 1159                }
 1160                catch (Exception ex)
 1161                {
 1162                    self.core.TrySetException(ex);
 1163                    return;
 1164                }
 1165
 1166                if (Interlocked.Increment(ref self.completedCount) == 7)
 1167                {
 1168                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7));
 1169                }
 1170            }
 1171
 1172            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T3>.Awaiter 
 1173            {
 1174                try
 1175                {
 1176                    self.t3 = awaiter.GetResult();
 1177                }
 1178                catch (Exception ex)
 1179                {
 1180                    self.core.TrySetException(ex);
 1181                    return;
 1182                }
 1183
 1184                if (Interlocked.Increment(ref self.completedCount) == 7)
 1185                {
 1186                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7));
 1187                }
 1188            }
 1189
 1190            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T4>.Awaiter 
 1191            {
 1192                try
 1193                {
 1194                    self.t4 = awaiter.GetResult();
 1195                }
 1196                catch (Exception ex)
 1197                {
 1198                    self.core.TrySetException(ex);
 1199                    return;
 1200                }
 1201
 1202                if (Interlocked.Increment(ref self.completedCount) == 7)
 1203                {
 1204                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7));
 1205                }
 1206            }
 1207
 1208            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T5>.Awaiter 
 1209            {
 1210                try
 1211                {
 1212                    self.t5 = awaiter.GetResult();
 1213                }
 1214                catch (Exception ex)
 1215                {
 1216                    self.core.TrySetException(ex);
 1217                    return;
 1218                }
 1219
 1220                if (Interlocked.Increment(ref self.completedCount) == 7)
 1221                {
 1222                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7));
 1223                }
 1224            }
 1225
 1226            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T6>.Awaiter 
 1227            {
 1228                try
 1229                {
 1230                    self.t6 = awaiter.GetResult();
 1231                }
 1232                catch (Exception ex)
 1233                {
 1234                    self.core.TrySetException(ex);
 1235                    return;
 1236                }
 1237
 1238                if (Interlocked.Increment(ref self.completedCount) == 7)
 1239                {
 1240                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7));
 1241                }
 1242            }
 1243
 1244            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T7>.Awaiter 
 1245            {
 1246                try
 1247                {
 1248                    self.t7 = awaiter.GetResult();
 1249                }
 1250                catch (Exception ex)
 1251                {
 1252                    self.core.TrySetException(ex);
 1253                    return;
 1254                }
 1255
 1256                if (Interlocked.Increment(ref self.completedCount) == 7)
 1257                {
 1258                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7));
 1259                }
 1260            }
 1261
 1262
 1263            public (T1, T2, T3, T4, T5, T6, T7) GetResult(short token)
 1264            {
 1265                TaskTracker.RemoveTracking(this);
 1266                GC.SuppressFinalize(this);
 1267                return core.GetResult(token);
 1268            }
 1269
 1270            void IUniTaskSource.GetResult(short token)
 1271            {
 1272                GetResult(token);
 1273            }
 1274
 1275            public UniTaskStatus GetStatus(short token)
 1276            {
 1277                return core.GetStatus(token);
 1278            }
 1279
 1280            public UniTaskStatus UnsafeGetStatus()
 1281            {
 1282                return core.UnsafeGetStatus();
 1283            }
 1284
 1285            public void OnCompleted(Action<object> continuation, object state, short token)
 1286            {
 1287                core.OnCompleted(continuation, state, token);
 1288            }
 1289        }
 1290
 1291        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8)> WhenAll<T1, T2, T3, T4, T5, T6, T7, T8>(UniTask<T1> task
 01292        {
 01293            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 01294            {
 01295                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8)>((task1.GetAwaiter().GetResult(), task2.GetAwaiter()
 1296            }
 1297
 01298            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8)>(new WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>(task
 01299        }
 1300
 1301        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> : IUniTaskSource<(T1, T2, T3, T4, T5, T6, T7, T8)>
 1302        {
 1303            T1 t1 = default;
 1304            T2 t2 = default;
 1305            T3 t3 = default;
 1306            T4 t4 = default;
 1307            T5 t5 = default;
 1308            T6 t6 = default;
 1309            T7 t7 = default;
 1310            T8 t8 = default;
 1311            int completedCount;
 1312            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8)> core;
 1313
 1314            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 1315            {
 1316                TaskTracker.TrackActiveTask(this, 3);
 1317
 1318                this.completedCount = 0;
 1319                {
 1320                    var awaiter = task1.GetAwaiter();
 1321                    if (awaiter.IsCompleted)
 1322                    {
 1323                        TryInvokeContinuationT1(this, awaiter);
 1324                    }
 1325                    else
 1326                    {
 1327                        awaiter.SourceOnCompleted(state =>
 1328                        {
 1329                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T1>.Await
 1330                            {
 1331                                TryInvokeContinuationT1(t.Item1, t.Item2);
 1332                            }
 1333                        }, StateTuple.Create(this, awaiter));
 1334                    }
 1335                }
 1336                {
 1337                    var awaiter = task2.GetAwaiter();
 1338                    if (awaiter.IsCompleted)
 1339                    {
 1340                        TryInvokeContinuationT2(this, awaiter);
 1341                    }
 1342                    else
 1343                    {
 1344                        awaiter.SourceOnCompleted(state =>
 1345                        {
 1346                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T2>.Await
 1347                            {
 1348                                TryInvokeContinuationT2(t.Item1, t.Item2);
 1349                            }
 1350                        }, StateTuple.Create(this, awaiter));
 1351                    }
 1352                }
 1353                {
 1354                    var awaiter = task3.GetAwaiter();
 1355                    if (awaiter.IsCompleted)
 1356                    {
 1357                        TryInvokeContinuationT3(this, awaiter);
 1358                    }
 1359                    else
 1360                    {
 1361                        awaiter.SourceOnCompleted(state =>
 1362                        {
 1363                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T3>.Await
 1364                            {
 1365                                TryInvokeContinuationT3(t.Item1, t.Item2);
 1366                            }
 1367                        }, StateTuple.Create(this, awaiter));
 1368                    }
 1369                }
 1370                {
 1371                    var awaiter = task4.GetAwaiter();
 1372                    if (awaiter.IsCompleted)
 1373                    {
 1374                        TryInvokeContinuationT4(this, awaiter);
 1375                    }
 1376                    else
 1377                    {
 1378                        awaiter.SourceOnCompleted(state =>
 1379                        {
 1380                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T4>.Await
 1381                            {
 1382                                TryInvokeContinuationT4(t.Item1, t.Item2);
 1383                            }
 1384                        }, StateTuple.Create(this, awaiter));
 1385                    }
 1386                }
 1387                {
 1388                    var awaiter = task5.GetAwaiter();
 1389                    if (awaiter.IsCompleted)
 1390                    {
 1391                        TryInvokeContinuationT5(this, awaiter);
 1392                    }
 1393                    else
 1394                    {
 1395                        awaiter.SourceOnCompleted(state =>
 1396                        {
 1397                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T5>.Await
 1398                            {
 1399                                TryInvokeContinuationT5(t.Item1, t.Item2);
 1400                            }
 1401                        }, StateTuple.Create(this, awaiter));
 1402                    }
 1403                }
 1404                {
 1405                    var awaiter = task6.GetAwaiter();
 1406                    if (awaiter.IsCompleted)
 1407                    {
 1408                        TryInvokeContinuationT6(this, awaiter);
 1409                    }
 1410                    else
 1411                    {
 1412                        awaiter.SourceOnCompleted(state =>
 1413                        {
 1414                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T6>.Await
 1415                            {
 1416                                TryInvokeContinuationT6(t.Item1, t.Item2);
 1417                            }
 1418                        }, StateTuple.Create(this, awaiter));
 1419                    }
 1420                }
 1421                {
 1422                    var awaiter = task7.GetAwaiter();
 1423                    if (awaiter.IsCompleted)
 1424                    {
 1425                        TryInvokeContinuationT7(this, awaiter);
 1426                    }
 1427                    else
 1428                    {
 1429                        awaiter.SourceOnCompleted(state =>
 1430                        {
 1431                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T7>.Await
 1432                            {
 1433                                TryInvokeContinuationT7(t.Item1, t.Item2);
 1434                            }
 1435                        }, StateTuple.Create(this, awaiter));
 1436                    }
 1437                }
 1438                {
 1439                    var awaiter = task8.GetAwaiter();
 1440                    if (awaiter.IsCompleted)
 1441                    {
 1442                        TryInvokeContinuationT8(this, awaiter);
 1443                    }
 1444                    else
 1445                    {
 1446                        awaiter.SourceOnCompleted(state =>
 1447                        {
 1448                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T8>.Await
 1449                            {
 1450                                TryInvokeContinuationT8(t.Item1, t.Item2);
 1451                            }
 1452                        }, StateTuple.Create(this, awaiter));
 1453                    }
 1454                }
 1455            }
 1456
 1457            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T1>.Awai
 1458            {
 1459                try
 1460                {
 1461                    self.t1 = awaiter.GetResult();
 1462                }
 1463                catch (Exception ex)
 1464                {
 1465                    self.core.TrySetException(ex);
 1466                    return;
 1467                }
 1468
 1469                if (Interlocked.Increment(ref self.completedCount) == 8)
 1470                {
 1471                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1472                }
 1473            }
 1474
 1475            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T2>.Awai
 1476            {
 1477                try
 1478                {
 1479                    self.t2 = awaiter.GetResult();
 1480                }
 1481                catch (Exception ex)
 1482                {
 1483                    self.core.TrySetException(ex);
 1484                    return;
 1485                }
 1486
 1487                if (Interlocked.Increment(ref self.completedCount) == 8)
 1488                {
 1489                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1490                }
 1491            }
 1492
 1493            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T3>.Awai
 1494            {
 1495                try
 1496                {
 1497                    self.t3 = awaiter.GetResult();
 1498                }
 1499                catch (Exception ex)
 1500                {
 1501                    self.core.TrySetException(ex);
 1502                    return;
 1503                }
 1504
 1505                if (Interlocked.Increment(ref self.completedCount) == 8)
 1506                {
 1507                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1508                }
 1509            }
 1510
 1511            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T4>.Awai
 1512            {
 1513                try
 1514                {
 1515                    self.t4 = awaiter.GetResult();
 1516                }
 1517                catch (Exception ex)
 1518                {
 1519                    self.core.TrySetException(ex);
 1520                    return;
 1521                }
 1522
 1523                if (Interlocked.Increment(ref self.completedCount) == 8)
 1524                {
 1525                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1526                }
 1527            }
 1528
 1529            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T5>.Awai
 1530            {
 1531                try
 1532                {
 1533                    self.t5 = awaiter.GetResult();
 1534                }
 1535                catch (Exception ex)
 1536                {
 1537                    self.core.TrySetException(ex);
 1538                    return;
 1539                }
 1540
 1541                if (Interlocked.Increment(ref self.completedCount) == 8)
 1542                {
 1543                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1544                }
 1545            }
 1546
 1547            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T6>.Awai
 1548            {
 1549                try
 1550                {
 1551                    self.t6 = awaiter.GetResult();
 1552                }
 1553                catch (Exception ex)
 1554                {
 1555                    self.core.TrySetException(ex);
 1556                    return;
 1557                }
 1558
 1559                if (Interlocked.Increment(ref self.completedCount) == 8)
 1560                {
 1561                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1562                }
 1563            }
 1564
 1565            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T7>.Awai
 1566            {
 1567                try
 1568                {
 1569                    self.t7 = awaiter.GetResult();
 1570                }
 1571                catch (Exception ex)
 1572                {
 1573                    self.core.TrySetException(ex);
 1574                    return;
 1575                }
 1576
 1577                if (Interlocked.Increment(ref self.completedCount) == 8)
 1578                {
 1579                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1580                }
 1581            }
 1582
 1583            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T8>.Awai
 1584            {
 1585                try
 1586                {
 1587                    self.t8 = awaiter.GetResult();
 1588                }
 1589                catch (Exception ex)
 1590                {
 1591                    self.core.TrySetException(ex);
 1592                    return;
 1593                }
 1594
 1595                if (Interlocked.Increment(ref self.completedCount) == 8)
 1596                {
 1597                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8));
 1598                }
 1599            }
 1600
 1601
 1602            public (T1, T2, T3, T4, T5, T6, T7, T8) GetResult(short token)
 1603            {
 1604                TaskTracker.RemoveTracking(this);
 1605                GC.SuppressFinalize(this);
 1606                return core.GetResult(token);
 1607            }
 1608
 1609            void IUniTaskSource.GetResult(short token)
 1610            {
 1611                GetResult(token);
 1612            }
 1613
 1614            public UniTaskStatus GetStatus(short token)
 1615            {
 1616                return core.GetStatus(token);
 1617            }
 1618
 1619            public UniTaskStatus UnsafeGetStatus()
 1620            {
 1621                return core.UnsafeGetStatus();
 1622            }
 1623
 1624            public void OnCompleted(Action<object> continuation, object state, short token)
 1625            {
 1626                core.OnCompleted(continuation, state, token);
 1627            }
 1628        }
 1629
 1630        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> WhenAll<T1, T2, T3, T4, T5, T6, T7, T8, T9>(UniTask<
 01631        {
 01632            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 01633            {
 01634                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>((task1.GetAwaiter().GetResult(), task2.GetAwait
 1635            }
 1636
 01637            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>(new WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, 
 01638        }
 1639
 1640        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> : IUniTaskSource<(T1, T2, T3, T4, T5, T6, T7, T8
 1641        {
 1642            T1 t1 = default;
 1643            T2 t2 = default;
 1644            T3 t3 = default;
 1645            T4 t4 = default;
 1646            T5 t5 = default;
 1647            T6 t6 = default;
 1648            T7 t7 = default;
 1649            T8 t8 = default;
 1650            T9 t9 = default;
 1651            int completedCount;
 1652            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> core;
 1653
 1654            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 1655            {
 1656                TaskTracker.TrackActiveTask(this, 3);
 1657
 1658                this.completedCount = 0;
 1659                {
 1660                    var awaiter = task1.GetAwaiter();
 1661                    if (awaiter.IsCompleted)
 1662                    {
 1663                        TryInvokeContinuationT1(this, awaiter);
 1664                    }
 1665                    else
 1666                    {
 1667                        awaiter.SourceOnCompleted(state =>
 1668                        {
 1669                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T1>.A
 1670                            {
 1671                                TryInvokeContinuationT1(t.Item1, t.Item2);
 1672                            }
 1673                        }, StateTuple.Create(this, awaiter));
 1674                    }
 1675                }
 1676                {
 1677                    var awaiter = task2.GetAwaiter();
 1678                    if (awaiter.IsCompleted)
 1679                    {
 1680                        TryInvokeContinuationT2(this, awaiter);
 1681                    }
 1682                    else
 1683                    {
 1684                        awaiter.SourceOnCompleted(state =>
 1685                        {
 1686                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T2>.A
 1687                            {
 1688                                TryInvokeContinuationT2(t.Item1, t.Item2);
 1689                            }
 1690                        }, StateTuple.Create(this, awaiter));
 1691                    }
 1692                }
 1693                {
 1694                    var awaiter = task3.GetAwaiter();
 1695                    if (awaiter.IsCompleted)
 1696                    {
 1697                        TryInvokeContinuationT3(this, awaiter);
 1698                    }
 1699                    else
 1700                    {
 1701                        awaiter.SourceOnCompleted(state =>
 1702                        {
 1703                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T3>.A
 1704                            {
 1705                                TryInvokeContinuationT3(t.Item1, t.Item2);
 1706                            }
 1707                        }, StateTuple.Create(this, awaiter));
 1708                    }
 1709                }
 1710                {
 1711                    var awaiter = task4.GetAwaiter();
 1712                    if (awaiter.IsCompleted)
 1713                    {
 1714                        TryInvokeContinuationT4(this, awaiter);
 1715                    }
 1716                    else
 1717                    {
 1718                        awaiter.SourceOnCompleted(state =>
 1719                        {
 1720                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T4>.A
 1721                            {
 1722                                TryInvokeContinuationT4(t.Item1, t.Item2);
 1723                            }
 1724                        }, StateTuple.Create(this, awaiter));
 1725                    }
 1726                }
 1727                {
 1728                    var awaiter = task5.GetAwaiter();
 1729                    if (awaiter.IsCompleted)
 1730                    {
 1731                        TryInvokeContinuationT5(this, awaiter);
 1732                    }
 1733                    else
 1734                    {
 1735                        awaiter.SourceOnCompleted(state =>
 1736                        {
 1737                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T5>.A
 1738                            {
 1739                                TryInvokeContinuationT5(t.Item1, t.Item2);
 1740                            }
 1741                        }, StateTuple.Create(this, awaiter));
 1742                    }
 1743                }
 1744                {
 1745                    var awaiter = task6.GetAwaiter();
 1746                    if (awaiter.IsCompleted)
 1747                    {
 1748                        TryInvokeContinuationT6(this, awaiter);
 1749                    }
 1750                    else
 1751                    {
 1752                        awaiter.SourceOnCompleted(state =>
 1753                        {
 1754                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T6>.A
 1755                            {
 1756                                TryInvokeContinuationT6(t.Item1, t.Item2);
 1757                            }
 1758                        }, StateTuple.Create(this, awaiter));
 1759                    }
 1760                }
 1761                {
 1762                    var awaiter = task7.GetAwaiter();
 1763                    if (awaiter.IsCompleted)
 1764                    {
 1765                        TryInvokeContinuationT7(this, awaiter);
 1766                    }
 1767                    else
 1768                    {
 1769                        awaiter.SourceOnCompleted(state =>
 1770                        {
 1771                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T7>.A
 1772                            {
 1773                                TryInvokeContinuationT7(t.Item1, t.Item2);
 1774                            }
 1775                        }, StateTuple.Create(this, awaiter));
 1776                    }
 1777                }
 1778                {
 1779                    var awaiter = task8.GetAwaiter();
 1780                    if (awaiter.IsCompleted)
 1781                    {
 1782                        TryInvokeContinuationT8(this, awaiter);
 1783                    }
 1784                    else
 1785                    {
 1786                        awaiter.SourceOnCompleted(state =>
 1787                        {
 1788                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T8>.A
 1789                            {
 1790                                TryInvokeContinuationT8(t.Item1, t.Item2);
 1791                            }
 1792                        }, StateTuple.Create(this, awaiter));
 1793                    }
 1794                }
 1795                {
 1796                    var awaiter = task9.GetAwaiter();
 1797                    if (awaiter.IsCompleted)
 1798                    {
 1799                        TryInvokeContinuationT9(this, awaiter);
 1800                    }
 1801                    else
 1802                    {
 1803                        awaiter.SourceOnCompleted(state =>
 1804                        {
 1805                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T9>.A
 1806                            {
 1807                                TryInvokeContinuationT9(t.Item1, t.Item2);
 1808                            }
 1809                        }, StateTuple.Create(this, awaiter));
 1810                    }
 1811                }
 1812            }
 1813
 1814            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T1>.
 1815            {
 1816                try
 1817                {
 1818                    self.t1 = awaiter.GetResult();
 1819                }
 1820                catch (Exception ex)
 1821                {
 1822                    self.core.TrySetException(ex);
 1823                    return;
 1824                }
 1825
 1826                if (Interlocked.Increment(ref self.completedCount) == 9)
 1827                {
 1828                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1829                }
 1830            }
 1831
 1832            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T2>.
 1833            {
 1834                try
 1835                {
 1836                    self.t2 = awaiter.GetResult();
 1837                }
 1838                catch (Exception ex)
 1839                {
 1840                    self.core.TrySetException(ex);
 1841                    return;
 1842                }
 1843
 1844                if (Interlocked.Increment(ref self.completedCount) == 9)
 1845                {
 1846                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1847                }
 1848            }
 1849
 1850            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T3>.
 1851            {
 1852                try
 1853                {
 1854                    self.t3 = awaiter.GetResult();
 1855                }
 1856                catch (Exception ex)
 1857                {
 1858                    self.core.TrySetException(ex);
 1859                    return;
 1860                }
 1861
 1862                if (Interlocked.Increment(ref self.completedCount) == 9)
 1863                {
 1864                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1865                }
 1866            }
 1867
 1868            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T4>.
 1869            {
 1870                try
 1871                {
 1872                    self.t4 = awaiter.GetResult();
 1873                }
 1874                catch (Exception ex)
 1875                {
 1876                    self.core.TrySetException(ex);
 1877                    return;
 1878                }
 1879
 1880                if (Interlocked.Increment(ref self.completedCount) == 9)
 1881                {
 1882                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1883                }
 1884            }
 1885
 1886            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T5>.
 1887            {
 1888                try
 1889                {
 1890                    self.t5 = awaiter.GetResult();
 1891                }
 1892                catch (Exception ex)
 1893                {
 1894                    self.core.TrySetException(ex);
 1895                    return;
 1896                }
 1897
 1898                if (Interlocked.Increment(ref self.completedCount) == 9)
 1899                {
 1900                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1901                }
 1902            }
 1903
 1904            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T6>.
 1905            {
 1906                try
 1907                {
 1908                    self.t6 = awaiter.GetResult();
 1909                }
 1910                catch (Exception ex)
 1911                {
 1912                    self.core.TrySetException(ex);
 1913                    return;
 1914                }
 1915
 1916                if (Interlocked.Increment(ref self.completedCount) == 9)
 1917                {
 1918                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1919                }
 1920            }
 1921
 1922            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T7>.
 1923            {
 1924                try
 1925                {
 1926                    self.t7 = awaiter.GetResult();
 1927                }
 1928                catch (Exception ex)
 1929                {
 1930                    self.core.TrySetException(ex);
 1931                    return;
 1932                }
 1933
 1934                if (Interlocked.Increment(ref self.completedCount) == 9)
 1935                {
 1936                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1937                }
 1938            }
 1939
 1940            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T8>.
 1941            {
 1942                try
 1943                {
 1944                    self.t8 = awaiter.GetResult();
 1945                }
 1946                catch (Exception ex)
 1947                {
 1948                    self.core.TrySetException(ex);
 1949                    return;
 1950                }
 1951
 1952                if (Interlocked.Increment(ref self.completedCount) == 9)
 1953                {
 1954                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1955                }
 1956            }
 1957
 1958            static void TryInvokeContinuationT9(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T9>.
 1959            {
 1960                try
 1961                {
 1962                    self.t9 = awaiter.GetResult();
 1963                }
 1964                catch (Exception ex)
 1965                {
 1966                    self.core.TrySetException(ex);
 1967                    return;
 1968                }
 1969
 1970                if (Interlocked.Increment(ref self.completedCount) == 9)
 1971                {
 1972                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 1973                }
 1974            }
 1975
 1976
 1977            public (T1, T2, T3, T4, T5, T6, T7, T8, T9) GetResult(short token)
 1978            {
 1979                TaskTracker.RemoveTracking(this);
 1980                GC.SuppressFinalize(this);
 1981                return core.GetResult(token);
 1982            }
 1983
 1984            void IUniTaskSource.GetResult(short token)
 1985            {
 1986                GetResult(token);
 1987            }
 1988
 1989            public UniTaskStatus GetStatus(short token)
 1990            {
 1991                return core.GetStatus(token);
 1992            }
 1993
 1994            public UniTaskStatus UnsafeGetStatus()
 1995            {
 1996                return core.UnsafeGetStatus();
 1997            }
 1998
 1999            public void OnCompleted(Action<object> continuation, object state, short token)
 2000            {
 2001                core.OnCompleted(continuation, state, token);
 2002            }
 2003        }
 2004
 2005        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> WhenAll<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
 02006        {
 02007            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 02008            {
 02009                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>((task1.GetAwaiter().GetResult(), task2.Get
 2010            }
 2011
 02012            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>(new WhenAllPromise<T1, T2, T3, T4, T5, T6, T7,
 02013        }
 2014
 2015        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : IUniTaskSource<(T1, T2, T3, T4, T5, T6, T
 2016        {
 2017            T1 t1 = default;
 2018            T2 t2 = default;
 2019            T3 t3 = default;
 2020            T4 t4 = default;
 2021            T5 t5 = default;
 2022            T6 t6 = default;
 2023            T7 t7 = default;
 2024            T8 t8 = default;
 2025            T9 t9 = default;
 2026            T10 t10 = default;
 2027            int completedCount;
 2028            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> core;
 2029
 2030            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 2031            {
 2032                TaskTracker.TrackActiveTask(this, 3);
 2033
 2034                this.completedCount = 0;
 2035                {
 2036                    var awaiter = task1.GetAwaiter();
 2037                    if (awaiter.IsCompleted)
 2038                    {
 2039                        TryInvokeContinuationT1(this, awaiter);
 2040                    }
 2041                    else
 2042                    {
 2043                        awaiter.SourceOnCompleted(state =>
 2044                        {
 2045                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2046                            {
 2047                                TryInvokeContinuationT1(t.Item1, t.Item2);
 2048                            }
 2049                        }, StateTuple.Create(this, awaiter));
 2050                    }
 2051                }
 2052                {
 2053                    var awaiter = task2.GetAwaiter();
 2054                    if (awaiter.IsCompleted)
 2055                    {
 2056                        TryInvokeContinuationT2(this, awaiter);
 2057                    }
 2058                    else
 2059                    {
 2060                        awaiter.SourceOnCompleted(state =>
 2061                        {
 2062                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2063                            {
 2064                                TryInvokeContinuationT2(t.Item1, t.Item2);
 2065                            }
 2066                        }, StateTuple.Create(this, awaiter));
 2067                    }
 2068                }
 2069                {
 2070                    var awaiter = task3.GetAwaiter();
 2071                    if (awaiter.IsCompleted)
 2072                    {
 2073                        TryInvokeContinuationT3(this, awaiter);
 2074                    }
 2075                    else
 2076                    {
 2077                        awaiter.SourceOnCompleted(state =>
 2078                        {
 2079                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2080                            {
 2081                                TryInvokeContinuationT3(t.Item1, t.Item2);
 2082                            }
 2083                        }, StateTuple.Create(this, awaiter));
 2084                    }
 2085                }
 2086                {
 2087                    var awaiter = task4.GetAwaiter();
 2088                    if (awaiter.IsCompleted)
 2089                    {
 2090                        TryInvokeContinuationT4(this, awaiter);
 2091                    }
 2092                    else
 2093                    {
 2094                        awaiter.SourceOnCompleted(state =>
 2095                        {
 2096                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2097                            {
 2098                                TryInvokeContinuationT4(t.Item1, t.Item2);
 2099                            }
 2100                        }, StateTuple.Create(this, awaiter));
 2101                    }
 2102                }
 2103                {
 2104                    var awaiter = task5.GetAwaiter();
 2105                    if (awaiter.IsCompleted)
 2106                    {
 2107                        TryInvokeContinuationT5(this, awaiter);
 2108                    }
 2109                    else
 2110                    {
 2111                        awaiter.SourceOnCompleted(state =>
 2112                        {
 2113                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2114                            {
 2115                                TryInvokeContinuationT5(t.Item1, t.Item2);
 2116                            }
 2117                        }, StateTuple.Create(this, awaiter));
 2118                    }
 2119                }
 2120                {
 2121                    var awaiter = task6.GetAwaiter();
 2122                    if (awaiter.IsCompleted)
 2123                    {
 2124                        TryInvokeContinuationT6(this, awaiter);
 2125                    }
 2126                    else
 2127                    {
 2128                        awaiter.SourceOnCompleted(state =>
 2129                        {
 2130                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2131                            {
 2132                                TryInvokeContinuationT6(t.Item1, t.Item2);
 2133                            }
 2134                        }, StateTuple.Create(this, awaiter));
 2135                    }
 2136                }
 2137                {
 2138                    var awaiter = task7.GetAwaiter();
 2139                    if (awaiter.IsCompleted)
 2140                    {
 2141                        TryInvokeContinuationT7(this, awaiter);
 2142                    }
 2143                    else
 2144                    {
 2145                        awaiter.SourceOnCompleted(state =>
 2146                        {
 2147                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2148                            {
 2149                                TryInvokeContinuationT7(t.Item1, t.Item2);
 2150                            }
 2151                        }, StateTuple.Create(this, awaiter));
 2152                    }
 2153                }
 2154                {
 2155                    var awaiter = task8.GetAwaiter();
 2156                    if (awaiter.IsCompleted)
 2157                    {
 2158                        TryInvokeContinuationT8(this, awaiter);
 2159                    }
 2160                    else
 2161                    {
 2162                        awaiter.SourceOnCompleted(state =>
 2163                        {
 2164                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2165                            {
 2166                                TryInvokeContinuationT8(t.Item1, t.Item2);
 2167                            }
 2168                        }, StateTuple.Create(this, awaiter));
 2169                    }
 2170                }
 2171                {
 2172                    var awaiter = task9.GetAwaiter();
 2173                    if (awaiter.IsCompleted)
 2174                    {
 2175                        TryInvokeContinuationT9(this, awaiter);
 2176                    }
 2177                    else
 2178                    {
 2179                        awaiter.SourceOnCompleted(state =>
 2180                        {
 2181                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2182                            {
 2183                                TryInvokeContinuationT9(t.Item1, t.Item2);
 2184                            }
 2185                        }, StateTuple.Create(this, awaiter));
 2186                    }
 2187                }
 2188                {
 2189                    var awaiter = task10.GetAwaiter();
 2190                    if (awaiter.IsCompleted)
 2191                    {
 2192                        TryInvokeContinuationT10(this, awaiter);
 2193                    }
 2194                    else
 2195                    {
 2196                        awaiter.SourceOnCompleted(state =>
 2197                        {
 2198                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2199                            {
 2200                                TryInvokeContinuationT10(t.Item1, t.Item2);
 2201                            }
 2202                        }, StateTuple.Create(this, awaiter));
 2203                    }
 2204                }
 2205            }
 2206
 2207            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2208            {
 2209                try
 2210                {
 2211                    self.t1 = awaiter.GetResult();
 2212                }
 2213                catch (Exception ex)
 2214                {
 2215                    self.core.TrySetException(ex);
 2216                    return;
 2217                }
 2218
 2219                if (Interlocked.Increment(ref self.completedCount) == 10)
 2220                {
 2221                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2222                }
 2223            }
 2224
 2225            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2226            {
 2227                try
 2228                {
 2229                    self.t2 = awaiter.GetResult();
 2230                }
 2231                catch (Exception ex)
 2232                {
 2233                    self.core.TrySetException(ex);
 2234                    return;
 2235                }
 2236
 2237                if (Interlocked.Increment(ref self.completedCount) == 10)
 2238                {
 2239                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2240                }
 2241            }
 2242
 2243            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2244            {
 2245                try
 2246                {
 2247                    self.t3 = awaiter.GetResult();
 2248                }
 2249                catch (Exception ex)
 2250                {
 2251                    self.core.TrySetException(ex);
 2252                    return;
 2253                }
 2254
 2255                if (Interlocked.Increment(ref self.completedCount) == 10)
 2256                {
 2257                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2258                }
 2259            }
 2260
 2261            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2262            {
 2263                try
 2264                {
 2265                    self.t4 = awaiter.GetResult();
 2266                }
 2267                catch (Exception ex)
 2268                {
 2269                    self.core.TrySetException(ex);
 2270                    return;
 2271                }
 2272
 2273                if (Interlocked.Increment(ref self.completedCount) == 10)
 2274                {
 2275                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2276                }
 2277            }
 2278
 2279            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2280            {
 2281                try
 2282                {
 2283                    self.t5 = awaiter.GetResult();
 2284                }
 2285                catch (Exception ex)
 2286                {
 2287                    self.core.TrySetException(ex);
 2288                    return;
 2289                }
 2290
 2291                if (Interlocked.Increment(ref self.completedCount) == 10)
 2292                {
 2293                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2294                }
 2295            }
 2296
 2297            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2298            {
 2299                try
 2300                {
 2301                    self.t6 = awaiter.GetResult();
 2302                }
 2303                catch (Exception ex)
 2304                {
 2305                    self.core.TrySetException(ex);
 2306                    return;
 2307                }
 2308
 2309                if (Interlocked.Increment(ref self.completedCount) == 10)
 2310                {
 2311                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2312                }
 2313            }
 2314
 2315            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2316            {
 2317                try
 2318                {
 2319                    self.t7 = awaiter.GetResult();
 2320                }
 2321                catch (Exception ex)
 2322                {
 2323                    self.core.TrySetException(ex);
 2324                    return;
 2325                }
 2326
 2327                if (Interlocked.Increment(ref self.completedCount) == 10)
 2328                {
 2329                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2330                }
 2331            }
 2332
 2333            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2334            {
 2335                try
 2336                {
 2337                    self.t8 = awaiter.GetResult();
 2338                }
 2339                catch (Exception ex)
 2340                {
 2341                    self.core.TrySetException(ex);
 2342                    return;
 2343                }
 2344
 2345                if (Interlocked.Increment(ref self.completedCount) == 10)
 2346                {
 2347                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2348                }
 2349            }
 2350
 2351            static void TryInvokeContinuationT9(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2352            {
 2353                try
 2354                {
 2355                    self.t9 = awaiter.GetResult();
 2356                }
 2357                catch (Exception ex)
 2358                {
 2359                    self.core.TrySetException(ex);
 2360                    return;
 2361                }
 2362
 2363                if (Interlocked.Increment(ref self.completedCount) == 10)
 2364                {
 2365                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2366                }
 2367            }
 2368
 2369            static void TryInvokeContinuationT10(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTas
 2370            {
 2371                try
 2372                {
 2373                    self.t10 = awaiter.GetResult();
 2374                }
 2375                catch (Exception ex)
 2376                {
 2377                    self.core.TrySetException(ex);
 2378                    return;
 2379                }
 2380
 2381                if (Interlocked.Increment(ref self.completedCount) == 10)
 2382                {
 2383                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2384                }
 2385            }
 2386
 2387
 2388            public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) GetResult(short token)
 2389            {
 2390                TaskTracker.RemoveTracking(this);
 2391                GC.SuppressFinalize(this);
 2392                return core.GetResult(token);
 2393            }
 2394
 2395            void IUniTaskSource.GetResult(short token)
 2396            {
 2397                GetResult(token);
 2398            }
 2399
 2400            public UniTaskStatus GetStatus(short token)
 2401            {
 2402                return core.GetStatus(token);
 2403            }
 2404
 2405            public UniTaskStatus UnsafeGetStatus()
 2406            {
 2407                return core.UnsafeGetStatus();
 2408            }
 2409
 2410            public void OnCompleted(Action<object> continuation, object state, short token)
 2411            {
 2412                core.OnCompleted(continuation, state, token);
 2413            }
 2414        }
 2415
 2416        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> WhenAll<T1, T2, T3, T4, T5, T6, T7, T8, T9
 02417        {
 02418            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 02419            {
 02420                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>((task1.GetAwaiter().GetResult(), task
 2421            }
 2422
 02423            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>(new WhenAllPromise<T1, T2, T3, T4, T5, T6
 02424        }
 2425
 2426        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : IUniTaskSource<(T1, T2, T3, T4, T5, 
 2427        {
 2428            T1 t1 = default;
 2429            T2 t2 = default;
 2430            T3 t3 = default;
 2431            T4 t4 = default;
 2432            T5 t5 = default;
 2433            T6 t6 = default;
 2434            T7 t7 = default;
 2435            T8 t8 = default;
 2436            T9 t9 = default;
 2437            T10 t10 = default;
 2438            T11 t11 = default;
 2439            int completedCount;
 2440            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> core;
 2441
 2442            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 2443            {
 2444                TaskTracker.TrackActiveTask(this, 3);
 2445
 2446                this.completedCount = 0;
 2447                {
 2448                    var awaiter = task1.GetAwaiter();
 2449                    if (awaiter.IsCompleted)
 2450                    {
 2451                        TryInvokeContinuationT1(this, awaiter);
 2452                    }
 2453                    else
 2454                    {
 2455                        awaiter.SourceOnCompleted(state =>
 2456                        {
 2457                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2458                            {
 2459                                TryInvokeContinuationT1(t.Item1, t.Item2);
 2460                            }
 2461                        }, StateTuple.Create(this, awaiter));
 2462                    }
 2463                }
 2464                {
 2465                    var awaiter = task2.GetAwaiter();
 2466                    if (awaiter.IsCompleted)
 2467                    {
 2468                        TryInvokeContinuationT2(this, awaiter);
 2469                    }
 2470                    else
 2471                    {
 2472                        awaiter.SourceOnCompleted(state =>
 2473                        {
 2474                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2475                            {
 2476                                TryInvokeContinuationT2(t.Item1, t.Item2);
 2477                            }
 2478                        }, StateTuple.Create(this, awaiter));
 2479                    }
 2480                }
 2481                {
 2482                    var awaiter = task3.GetAwaiter();
 2483                    if (awaiter.IsCompleted)
 2484                    {
 2485                        TryInvokeContinuationT3(this, awaiter);
 2486                    }
 2487                    else
 2488                    {
 2489                        awaiter.SourceOnCompleted(state =>
 2490                        {
 2491                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2492                            {
 2493                                TryInvokeContinuationT3(t.Item1, t.Item2);
 2494                            }
 2495                        }, StateTuple.Create(this, awaiter));
 2496                    }
 2497                }
 2498                {
 2499                    var awaiter = task4.GetAwaiter();
 2500                    if (awaiter.IsCompleted)
 2501                    {
 2502                        TryInvokeContinuationT4(this, awaiter);
 2503                    }
 2504                    else
 2505                    {
 2506                        awaiter.SourceOnCompleted(state =>
 2507                        {
 2508                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2509                            {
 2510                                TryInvokeContinuationT4(t.Item1, t.Item2);
 2511                            }
 2512                        }, StateTuple.Create(this, awaiter));
 2513                    }
 2514                }
 2515                {
 2516                    var awaiter = task5.GetAwaiter();
 2517                    if (awaiter.IsCompleted)
 2518                    {
 2519                        TryInvokeContinuationT5(this, awaiter);
 2520                    }
 2521                    else
 2522                    {
 2523                        awaiter.SourceOnCompleted(state =>
 2524                        {
 2525                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2526                            {
 2527                                TryInvokeContinuationT5(t.Item1, t.Item2);
 2528                            }
 2529                        }, StateTuple.Create(this, awaiter));
 2530                    }
 2531                }
 2532                {
 2533                    var awaiter = task6.GetAwaiter();
 2534                    if (awaiter.IsCompleted)
 2535                    {
 2536                        TryInvokeContinuationT6(this, awaiter);
 2537                    }
 2538                    else
 2539                    {
 2540                        awaiter.SourceOnCompleted(state =>
 2541                        {
 2542                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2543                            {
 2544                                TryInvokeContinuationT6(t.Item1, t.Item2);
 2545                            }
 2546                        }, StateTuple.Create(this, awaiter));
 2547                    }
 2548                }
 2549                {
 2550                    var awaiter = task7.GetAwaiter();
 2551                    if (awaiter.IsCompleted)
 2552                    {
 2553                        TryInvokeContinuationT7(this, awaiter);
 2554                    }
 2555                    else
 2556                    {
 2557                        awaiter.SourceOnCompleted(state =>
 2558                        {
 2559                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2560                            {
 2561                                TryInvokeContinuationT7(t.Item1, t.Item2);
 2562                            }
 2563                        }, StateTuple.Create(this, awaiter));
 2564                    }
 2565                }
 2566                {
 2567                    var awaiter = task8.GetAwaiter();
 2568                    if (awaiter.IsCompleted)
 2569                    {
 2570                        TryInvokeContinuationT8(this, awaiter);
 2571                    }
 2572                    else
 2573                    {
 2574                        awaiter.SourceOnCompleted(state =>
 2575                        {
 2576                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2577                            {
 2578                                TryInvokeContinuationT8(t.Item1, t.Item2);
 2579                            }
 2580                        }, StateTuple.Create(this, awaiter));
 2581                    }
 2582                }
 2583                {
 2584                    var awaiter = task9.GetAwaiter();
 2585                    if (awaiter.IsCompleted)
 2586                    {
 2587                        TryInvokeContinuationT9(this, awaiter);
 2588                    }
 2589                    else
 2590                    {
 2591                        awaiter.SourceOnCompleted(state =>
 2592                        {
 2593                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2594                            {
 2595                                TryInvokeContinuationT9(t.Item1, t.Item2);
 2596                            }
 2597                        }, StateTuple.Create(this, awaiter));
 2598                    }
 2599                }
 2600                {
 2601                    var awaiter = task10.GetAwaiter();
 2602                    if (awaiter.IsCompleted)
 2603                    {
 2604                        TryInvokeContinuationT10(this, awaiter);
 2605                    }
 2606                    else
 2607                    {
 2608                        awaiter.SourceOnCompleted(state =>
 2609                        {
 2610                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2611                            {
 2612                                TryInvokeContinuationT10(t.Item1, t.Item2);
 2613                            }
 2614                        }, StateTuple.Create(this, awaiter));
 2615                    }
 2616                }
 2617                {
 2618                    var awaiter = task11.GetAwaiter();
 2619                    if (awaiter.IsCompleted)
 2620                    {
 2621                        TryInvokeContinuationT11(this, awaiter);
 2622                    }
 2623                    else
 2624                    {
 2625                        awaiter.SourceOnCompleted(state =>
 2626                        {
 2627                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2628                            {
 2629                                TryInvokeContinuationT11(t.Item1, t.Item2);
 2630                            }
 2631                        }, StateTuple.Create(this, awaiter));
 2632                    }
 2633                }
 2634            }
 2635
 2636            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2637            {
 2638                try
 2639                {
 2640                    self.t1 = awaiter.GetResult();
 2641                }
 2642                catch (Exception ex)
 2643                {
 2644                    self.core.TrySetException(ex);
 2645                    return;
 2646                }
 2647
 2648                if (Interlocked.Increment(ref self.completedCount) == 11)
 2649                {
 2650                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2651                }
 2652            }
 2653
 2654            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2655            {
 2656                try
 2657                {
 2658                    self.t2 = awaiter.GetResult();
 2659                }
 2660                catch (Exception ex)
 2661                {
 2662                    self.core.TrySetException(ex);
 2663                    return;
 2664                }
 2665
 2666                if (Interlocked.Increment(ref self.completedCount) == 11)
 2667                {
 2668                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2669                }
 2670            }
 2671
 2672            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2673            {
 2674                try
 2675                {
 2676                    self.t3 = awaiter.GetResult();
 2677                }
 2678                catch (Exception ex)
 2679                {
 2680                    self.core.TrySetException(ex);
 2681                    return;
 2682                }
 2683
 2684                if (Interlocked.Increment(ref self.completedCount) == 11)
 2685                {
 2686                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2687                }
 2688            }
 2689
 2690            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2691            {
 2692                try
 2693                {
 2694                    self.t4 = awaiter.GetResult();
 2695                }
 2696                catch (Exception ex)
 2697                {
 2698                    self.core.TrySetException(ex);
 2699                    return;
 2700                }
 2701
 2702                if (Interlocked.Increment(ref self.completedCount) == 11)
 2703                {
 2704                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2705                }
 2706            }
 2707
 2708            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2709            {
 2710                try
 2711                {
 2712                    self.t5 = awaiter.GetResult();
 2713                }
 2714                catch (Exception ex)
 2715                {
 2716                    self.core.TrySetException(ex);
 2717                    return;
 2718                }
 2719
 2720                if (Interlocked.Increment(ref self.completedCount) == 11)
 2721                {
 2722                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2723                }
 2724            }
 2725
 2726            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2727            {
 2728                try
 2729                {
 2730                    self.t6 = awaiter.GetResult();
 2731                }
 2732                catch (Exception ex)
 2733                {
 2734                    self.core.TrySetException(ex);
 2735                    return;
 2736                }
 2737
 2738                if (Interlocked.Increment(ref self.completedCount) == 11)
 2739                {
 2740                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2741                }
 2742            }
 2743
 2744            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2745            {
 2746                try
 2747                {
 2748                    self.t7 = awaiter.GetResult();
 2749                }
 2750                catch (Exception ex)
 2751                {
 2752                    self.core.TrySetException(ex);
 2753                    return;
 2754                }
 2755
 2756                if (Interlocked.Increment(ref self.completedCount) == 11)
 2757                {
 2758                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2759                }
 2760            }
 2761
 2762            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2763            {
 2764                try
 2765                {
 2766                    self.t8 = awaiter.GetResult();
 2767                }
 2768                catch (Exception ex)
 2769                {
 2770                    self.core.TrySetException(ex);
 2771                    return;
 2772                }
 2773
 2774                if (Interlocked.Increment(ref self.completedCount) == 11)
 2775                {
 2776                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2777                }
 2778            }
 2779
 2780            static void TryInvokeContinuationT9(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2781            {
 2782                try
 2783                {
 2784                    self.t9 = awaiter.GetResult();
 2785                }
 2786                catch (Exception ex)
 2787                {
 2788                    self.core.TrySetException(ex);
 2789                    return;
 2790                }
 2791
 2792                if (Interlocked.Increment(ref self.completedCount) == 11)
 2793                {
 2794                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2795                }
 2796            }
 2797
 2798            static void TryInvokeContinuationT10(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in U
 2799            {
 2800                try
 2801                {
 2802                    self.t10 = awaiter.GetResult();
 2803                }
 2804                catch (Exception ex)
 2805                {
 2806                    self.core.TrySetException(ex);
 2807                    return;
 2808                }
 2809
 2810                if (Interlocked.Increment(ref self.completedCount) == 11)
 2811                {
 2812                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2813                }
 2814            }
 2815
 2816            static void TryInvokeContinuationT11(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in U
 2817            {
 2818                try
 2819                {
 2820                    self.t11 = awaiter.GetResult();
 2821                }
 2822                catch (Exception ex)
 2823                {
 2824                    self.core.TrySetException(ex);
 2825                    return;
 2826                }
 2827
 2828                if (Interlocked.Increment(ref self.completedCount) == 11)
 2829                {
 2830                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 2831                }
 2832            }
 2833
 2834
 2835            public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) GetResult(short token)
 2836            {
 2837                TaskTracker.RemoveTracking(this);
 2838                GC.SuppressFinalize(this);
 2839                return core.GetResult(token);
 2840            }
 2841
 2842            void IUniTaskSource.GetResult(short token)
 2843            {
 2844                GetResult(token);
 2845            }
 2846
 2847            public UniTaskStatus GetStatus(short token)
 2848            {
 2849                return core.GetStatus(token);
 2850            }
 2851
 2852            public UniTaskStatus UnsafeGetStatus()
 2853            {
 2854                return core.UnsafeGetStatus();
 2855            }
 2856
 2857            public void OnCompleted(Action<object> continuation, object state, short token)
 2858            {
 2859                core.OnCompleted(continuation, state, token);
 2860            }
 2861        }
 2862
 2863        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> WhenAll<T1, T2, T3, T4, T5, T6, T7, T
 02864        {
 02865            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 02866            {
 02867                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>((task1.GetAwaiter().GetResult(),
 2868            }
 2869
 02870            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>(new WhenAllPromise<T1, T2, T3, T4, T
 02871        }
 2872
 2873        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : IUniTaskSource<(T1, T2, T3, T4,
 2874        {
 2875            T1 t1 = default;
 2876            T2 t2 = default;
 2877            T3 t3 = default;
 2878            T4 t4 = default;
 2879            T5 t5 = default;
 2880            T6 t6 = default;
 2881            T7 t7 = default;
 2882            T8 t8 = default;
 2883            T9 t9 = default;
 2884            T10 t10 = default;
 2885            T11 t11 = default;
 2886            T12 t12 = default;
 2887            int completedCount;
 2888            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> core;
 2889
 2890            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 2891            {
 2892                TaskTracker.TrackActiveTask(this, 3);
 2893
 2894                this.completedCount = 0;
 2895                {
 2896                    var awaiter = task1.GetAwaiter();
 2897                    if (awaiter.IsCompleted)
 2898                    {
 2899                        TryInvokeContinuationT1(this, awaiter);
 2900                    }
 2901                    else
 2902                    {
 2903                        awaiter.SourceOnCompleted(state =>
 2904                        {
 2905                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2906                            {
 2907                                TryInvokeContinuationT1(t.Item1, t.Item2);
 2908                            }
 2909                        }, StateTuple.Create(this, awaiter));
 2910                    }
 2911                }
 2912                {
 2913                    var awaiter = task2.GetAwaiter();
 2914                    if (awaiter.IsCompleted)
 2915                    {
 2916                        TryInvokeContinuationT2(this, awaiter);
 2917                    }
 2918                    else
 2919                    {
 2920                        awaiter.SourceOnCompleted(state =>
 2921                        {
 2922                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2923                            {
 2924                                TryInvokeContinuationT2(t.Item1, t.Item2);
 2925                            }
 2926                        }, StateTuple.Create(this, awaiter));
 2927                    }
 2928                }
 2929                {
 2930                    var awaiter = task3.GetAwaiter();
 2931                    if (awaiter.IsCompleted)
 2932                    {
 2933                        TryInvokeContinuationT3(this, awaiter);
 2934                    }
 2935                    else
 2936                    {
 2937                        awaiter.SourceOnCompleted(state =>
 2938                        {
 2939                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2940                            {
 2941                                TryInvokeContinuationT3(t.Item1, t.Item2);
 2942                            }
 2943                        }, StateTuple.Create(this, awaiter));
 2944                    }
 2945                }
 2946                {
 2947                    var awaiter = task4.GetAwaiter();
 2948                    if (awaiter.IsCompleted)
 2949                    {
 2950                        TryInvokeContinuationT4(this, awaiter);
 2951                    }
 2952                    else
 2953                    {
 2954                        awaiter.SourceOnCompleted(state =>
 2955                        {
 2956                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2957                            {
 2958                                TryInvokeContinuationT4(t.Item1, t.Item2);
 2959                            }
 2960                        }, StateTuple.Create(this, awaiter));
 2961                    }
 2962                }
 2963                {
 2964                    var awaiter = task5.GetAwaiter();
 2965                    if (awaiter.IsCompleted)
 2966                    {
 2967                        TryInvokeContinuationT5(this, awaiter);
 2968                    }
 2969                    else
 2970                    {
 2971                        awaiter.SourceOnCompleted(state =>
 2972                        {
 2973                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2974                            {
 2975                                TryInvokeContinuationT5(t.Item1, t.Item2);
 2976                            }
 2977                        }, StateTuple.Create(this, awaiter));
 2978                    }
 2979                }
 2980                {
 2981                    var awaiter = task6.GetAwaiter();
 2982                    if (awaiter.IsCompleted)
 2983                    {
 2984                        TryInvokeContinuationT6(this, awaiter);
 2985                    }
 2986                    else
 2987                    {
 2988                        awaiter.SourceOnCompleted(state =>
 2989                        {
 2990                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2991                            {
 2992                                TryInvokeContinuationT6(t.Item1, t.Item2);
 2993                            }
 2994                        }, StateTuple.Create(this, awaiter));
 2995                    }
 2996                }
 2997                {
 2998                    var awaiter = task7.GetAwaiter();
 2999                    if (awaiter.IsCompleted)
 3000                    {
 3001                        TryInvokeContinuationT7(this, awaiter);
 3002                    }
 3003                    else
 3004                    {
 3005                        awaiter.SourceOnCompleted(state =>
 3006                        {
 3007                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3008                            {
 3009                                TryInvokeContinuationT7(t.Item1, t.Item2);
 3010                            }
 3011                        }, StateTuple.Create(this, awaiter));
 3012                    }
 3013                }
 3014                {
 3015                    var awaiter = task8.GetAwaiter();
 3016                    if (awaiter.IsCompleted)
 3017                    {
 3018                        TryInvokeContinuationT8(this, awaiter);
 3019                    }
 3020                    else
 3021                    {
 3022                        awaiter.SourceOnCompleted(state =>
 3023                        {
 3024                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3025                            {
 3026                                TryInvokeContinuationT8(t.Item1, t.Item2);
 3027                            }
 3028                        }, StateTuple.Create(this, awaiter));
 3029                    }
 3030                }
 3031                {
 3032                    var awaiter = task9.GetAwaiter();
 3033                    if (awaiter.IsCompleted)
 3034                    {
 3035                        TryInvokeContinuationT9(this, awaiter);
 3036                    }
 3037                    else
 3038                    {
 3039                        awaiter.SourceOnCompleted(state =>
 3040                        {
 3041                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3042                            {
 3043                                TryInvokeContinuationT9(t.Item1, t.Item2);
 3044                            }
 3045                        }, StateTuple.Create(this, awaiter));
 3046                    }
 3047                }
 3048                {
 3049                    var awaiter = task10.GetAwaiter();
 3050                    if (awaiter.IsCompleted)
 3051                    {
 3052                        TryInvokeContinuationT10(this, awaiter);
 3053                    }
 3054                    else
 3055                    {
 3056                        awaiter.SourceOnCompleted(state =>
 3057                        {
 3058                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3059                            {
 3060                                TryInvokeContinuationT10(t.Item1, t.Item2);
 3061                            }
 3062                        }, StateTuple.Create(this, awaiter));
 3063                    }
 3064                }
 3065                {
 3066                    var awaiter = task11.GetAwaiter();
 3067                    if (awaiter.IsCompleted)
 3068                    {
 3069                        TryInvokeContinuationT11(this, awaiter);
 3070                    }
 3071                    else
 3072                    {
 3073                        awaiter.SourceOnCompleted(state =>
 3074                        {
 3075                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3076                            {
 3077                                TryInvokeContinuationT11(t.Item1, t.Item2);
 3078                            }
 3079                        }, StateTuple.Create(this, awaiter));
 3080                    }
 3081                }
 3082                {
 3083                    var awaiter = task12.GetAwaiter();
 3084                    if (awaiter.IsCompleted)
 3085                    {
 3086                        TryInvokeContinuationT12(this, awaiter);
 3087                    }
 3088                    else
 3089                    {
 3090                        awaiter.SourceOnCompleted(state =>
 3091                        {
 3092                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3093                            {
 3094                                TryInvokeContinuationT12(t.Item1, t.Item2);
 3095                            }
 3096                        }, StateTuple.Create(this, awaiter));
 3097                    }
 3098                }
 3099            }
 3100
 3101            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3102            {
 3103                try
 3104                {
 3105                    self.t1 = awaiter.GetResult();
 3106                }
 3107                catch (Exception ex)
 3108                {
 3109                    self.core.TrySetException(ex);
 3110                    return;
 3111                }
 3112
 3113                if (Interlocked.Increment(ref self.completedCount) == 12)
 3114                {
 3115                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3116                }
 3117            }
 3118
 3119            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3120            {
 3121                try
 3122                {
 3123                    self.t2 = awaiter.GetResult();
 3124                }
 3125                catch (Exception ex)
 3126                {
 3127                    self.core.TrySetException(ex);
 3128                    return;
 3129                }
 3130
 3131                if (Interlocked.Increment(ref self.completedCount) == 12)
 3132                {
 3133                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3134                }
 3135            }
 3136
 3137            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3138            {
 3139                try
 3140                {
 3141                    self.t3 = awaiter.GetResult();
 3142                }
 3143                catch (Exception ex)
 3144                {
 3145                    self.core.TrySetException(ex);
 3146                    return;
 3147                }
 3148
 3149                if (Interlocked.Increment(ref self.completedCount) == 12)
 3150                {
 3151                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3152                }
 3153            }
 3154
 3155            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3156            {
 3157                try
 3158                {
 3159                    self.t4 = awaiter.GetResult();
 3160                }
 3161                catch (Exception ex)
 3162                {
 3163                    self.core.TrySetException(ex);
 3164                    return;
 3165                }
 3166
 3167                if (Interlocked.Increment(ref self.completedCount) == 12)
 3168                {
 3169                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3170                }
 3171            }
 3172
 3173            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3174            {
 3175                try
 3176                {
 3177                    self.t5 = awaiter.GetResult();
 3178                }
 3179                catch (Exception ex)
 3180                {
 3181                    self.core.TrySetException(ex);
 3182                    return;
 3183                }
 3184
 3185                if (Interlocked.Increment(ref self.completedCount) == 12)
 3186                {
 3187                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3188                }
 3189            }
 3190
 3191            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3192            {
 3193                try
 3194                {
 3195                    self.t6 = awaiter.GetResult();
 3196                }
 3197                catch (Exception ex)
 3198                {
 3199                    self.core.TrySetException(ex);
 3200                    return;
 3201                }
 3202
 3203                if (Interlocked.Increment(ref self.completedCount) == 12)
 3204                {
 3205                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3206                }
 3207            }
 3208
 3209            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3210            {
 3211                try
 3212                {
 3213                    self.t7 = awaiter.GetResult();
 3214                }
 3215                catch (Exception ex)
 3216                {
 3217                    self.core.TrySetException(ex);
 3218                    return;
 3219                }
 3220
 3221                if (Interlocked.Increment(ref self.completedCount) == 12)
 3222                {
 3223                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3224                }
 3225            }
 3226
 3227            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3228            {
 3229                try
 3230                {
 3231                    self.t8 = awaiter.GetResult();
 3232                }
 3233                catch (Exception ex)
 3234                {
 3235                    self.core.TrySetException(ex);
 3236                    return;
 3237                }
 3238
 3239                if (Interlocked.Increment(ref self.completedCount) == 12)
 3240                {
 3241                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3242                }
 3243            }
 3244
 3245            static void TryInvokeContinuationT9(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3246            {
 3247                try
 3248                {
 3249                    self.t9 = awaiter.GetResult();
 3250                }
 3251                catch (Exception ex)
 3252                {
 3253                    self.core.TrySetException(ex);
 3254                    return;
 3255                }
 3256
 3257                if (Interlocked.Increment(ref self.completedCount) == 12)
 3258                {
 3259                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3260                }
 3261            }
 3262
 3263            static void TryInvokeContinuationT10(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self,
 3264            {
 3265                try
 3266                {
 3267                    self.t10 = awaiter.GetResult();
 3268                }
 3269                catch (Exception ex)
 3270                {
 3271                    self.core.TrySetException(ex);
 3272                    return;
 3273                }
 3274
 3275                if (Interlocked.Increment(ref self.completedCount) == 12)
 3276                {
 3277                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3278                }
 3279            }
 3280
 3281            static void TryInvokeContinuationT11(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self,
 3282            {
 3283                try
 3284                {
 3285                    self.t11 = awaiter.GetResult();
 3286                }
 3287                catch (Exception ex)
 3288                {
 3289                    self.core.TrySetException(ex);
 3290                    return;
 3291                }
 3292
 3293                if (Interlocked.Increment(ref self.completedCount) == 12)
 3294                {
 3295                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3296                }
 3297            }
 3298
 3299            static void TryInvokeContinuationT12(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self,
 3300            {
 3301                try
 3302                {
 3303                    self.t12 = awaiter.GetResult();
 3304                }
 3305                catch (Exception ex)
 3306                {
 3307                    self.core.TrySetException(ex);
 3308                    return;
 3309                }
 3310
 3311                if (Interlocked.Increment(ref self.completedCount) == 12)
 3312                {
 3313                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3314                }
 3315            }
 3316
 3317
 3318            public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) GetResult(short token)
 3319            {
 3320                TaskTracker.RemoveTracking(this);
 3321                GC.SuppressFinalize(this);
 3322                return core.GetResult(token);
 3323            }
 3324
 3325            void IUniTaskSource.GetResult(short token)
 3326            {
 3327                GetResult(token);
 3328            }
 3329
 3330            public UniTaskStatus GetStatus(short token)
 3331            {
 3332                return core.GetStatus(token);
 3333            }
 3334
 3335            public UniTaskStatus UnsafeGetStatus()
 3336            {
 3337                return core.UnsafeGetStatus();
 3338            }
 3339
 3340            public void OnCompleted(Action<object> continuation, object state, short token)
 3341            {
 3342                core.OnCompleted(continuation, state, token);
 3343            }
 3344        }
 3345
 3346        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> WhenAll<T1, T2, T3, T4, T5, T6, 
 03347        {
 03348            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 03349            {
 03350                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>((task1.GetAwaiter().GetResu
 3351            }
 3352
 03353            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>(new WhenAllPromise<T1, T2, T3, 
 03354        }
 3355
 3356        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : IUniTaskSource<(T1, T2, T3
 3357        {
 3358            T1 t1 = default;
 3359            T2 t2 = default;
 3360            T3 t3 = default;
 3361            T4 t4 = default;
 3362            T5 t5 = default;
 3363            T6 t6 = default;
 3364            T7 t7 = default;
 3365            T8 t8 = default;
 3366            T9 t9 = default;
 3367            T10 t10 = default;
 3368            T11 t11 = default;
 3369            T12 t12 = default;
 3370            T13 t13 = default;
 3371            int completedCount;
 3372            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> core;
 3373
 3374            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 3375            {
 3376                TaskTracker.TrackActiveTask(this, 3);
 3377
 3378                this.completedCount = 0;
 3379                {
 3380                    var awaiter = task1.GetAwaiter();
 3381                    if (awaiter.IsCompleted)
 3382                    {
 3383                        TryInvokeContinuationT1(this, awaiter);
 3384                    }
 3385                    else
 3386                    {
 3387                        awaiter.SourceOnCompleted(state =>
 3388                        {
 3389                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3390                            {
 3391                                TryInvokeContinuationT1(t.Item1, t.Item2);
 3392                            }
 3393                        }, StateTuple.Create(this, awaiter));
 3394                    }
 3395                }
 3396                {
 3397                    var awaiter = task2.GetAwaiter();
 3398                    if (awaiter.IsCompleted)
 3399                    {
 3400                        TryInvokeContinuationT2(this, awaiter);
 3401                    }
 3402                    else
 3403                    {
 3404                        awaiter.SourceOnCompleted(state =>
 3405                        {
 3406                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3407                            {
 3408                                TryInvokeContinuationT2(t.Item1, t.Item2);
 3409                            }
 3410                        }, StateTuple.Create(this, awaiter));
 3411                    }
 3412                }
 3413                {
 3414                    var awaiter = task3.GetAwaiter();
 3415                    if (awaiter.IsCompleted)
 3416                    {
 3417                        TryInvokeContinuationT3(this, awaiter);
 3418                    }
 3419                    else
 3420                    {
 3421                        awaiter.SourceOnCompleted(state =>
 3422                        {
 3423                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3424                            {
 3425                                TryInvokeContinuationT3(t.Item1, t.Item2);
 3426                            }
 3427                        }, StateTuple.Create(this, awaiter));
 3428                    }
 3429                }
 3430                {
 3431                    var awaiter = task4.GetAwaiter();
 3432                    if (awaiter.IsCompleted)
 3433                    {
 3434                        TryInvokeContinuationT4(this, awaiter);
 3435                    }
 3436                    else
 3437                    {
 3438                        awaiter.SourceOnCompleted(state =>
 3439                        {
 3440                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3441                            {
 3442                                TryInvokeContinuationT4(t.Item1, t.Item2);
 3443                            }
 3444                        }, StateTuple.Create(this, awaiter));
 3445                    }
 3446                }
 3447                {
 3448                    var awaiter = task5.GetAwaiter();
 3449                    if (awaiter.IsCompleted)
 3450                    {
 3451                        TryInvokeContinuationT5(this, awaiter);
 3452                    }
 3453                    else
 3454                    {
 3455                        awaiter.SourceOnCompleted(state =>
 3456                        {
 3457                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3458                            {
 3459                                TryInvokeContinuationT5(t.Item1, t.Item2);
 3460                            }
 3461                        }, StateTuple.Create(this, awaiter));
 3462                    }
 3463                }
 3464                {
 3465                    var awaiter = task6.GetAwaiter();
 3466                    if (awaiter.IsCompleted)
 3467                    {
 3468                        TryInvokeContinuationT6(this, awaiter);
 3469                    }
 3470                    else
 3471                    {
 3472                        awaiter.SourceOnCompleted(state =>
 3473                        {
 3474                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3475                            {
 3476                                TryInvokeContinuationT6(t.Item1, t.Item2);
 3477                            }
 3478                        }, StateTuple.Create(this, awaiter));
 3479                    }
 3480                }
 3481                {
 3482                    var awaiter = task7.GetAwaiter();
 3483                    if (awaiter.IsCompleted)
 3484                    {
 3485                        TryInvokeContinuationT7(this, awaiter);
 3486                    }
 3487                    else
 3488                    {
 3489                        awaiter.SourceOnCompleted(state =>
 3490                        {
 3491                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3492                            {
 3493                                TryInvokeContinuationT7(t.Item1, t.Item2);
 3494                            }
 3495                        }, StateTuple.Create(this, awaiter));
 3496                    }
 3497                }
 3498                {
 3499                    var awaiter = task8.GetAwaiter();
 3500                    if (awaiter.IsCompleted)
 3501                    {
 3502                        TryInvokeContinuationT8(this, awaiter);
 3503                    }
 3504                    else
 3505                    {
 3506                        awaiter.SourceOnCompleted(state =>
 3507                        {
 3508                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3509                            {
 3510                                TryInvokeContinuationT8(t.Item1, t.Item2);
 3511                            }
 3512                        }, StateTuple.Create(this, awaiter));
 3513                    }
 3514                }
 3515                {
 3516                    var awaiter = task9.GetAwaiter();
 3517                    if (awaiter.IsCompleted)
 3518                    {
 3519                        TryInvokeContinuationT9(this, awaiter);
 3520                    }
 3521                    else
 3522                    {
 3523                        awaiter.SourceOnCompleted(state =>
 3524                        {
 3525                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3526                            {
 3527                                TryInvokeContinuationT9(t.Item1, t.Item2);
 3528                            }
 3529                        }, StateTuple.Create(this, awaiter));
 3530                    }
 3531                }
 3532                {
 3533                    var awaiter = task10.GetAwaiter();
 3534                    if (awaiter.IsCompleted)
 3535                    {
 3536                        TryInvokeContinuationT10(this, awaiter);
 3537                    }
 3538                    else
 3539                    {
 3540                        awaiter.SourceOnCompleted(state =>
 3541                        {
 3542                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3543                            {
 3544                                TryInvokeContinuationT10(t.Item1, t.Item2);
 3545                            }
 3546                        }, StateTuple.Create(this, awaiter));
 3547                    }
 3548                }
 3549                {
 3550                    var awaiter = task11.GetAwaiter();
 3551                    if (awaiter.IsCompleted)
 3552                    {
 3553                        TryInvokeContinuationT11(this, awaiter);
 3554                    }
 3555                    else
 3556                    {
 3557                        awaiter.SourceOnCompleted(state =>
 3558                        {
 3559                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3560                            {
 3561                                TryInvokeContinuationT11(t.Item1, t.Item2);
 3562                            }
 3563                        }, StateTuple.Create(this, awaiter));
 3564                    }
 3565                }
 3566                {
 3567                    var awaiter = task12.GetAwaiter();
 3568                    if (awaiter.IsCompleted)
 3569                    {
 3570                        TryInvokeContinuationT12(this, awaiter);
 3571                    }
 3572                    else
 3573                    {
 3574                        awaiter.SourceOnCompleted(state =>
 3575                        {
 3576                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3577                            {
 3578                                TryInvokeContinuationT12(t.Item1, t.Item2);
 3579                            }
 3580                        }, StateTuple.Create(this, awaiter));
 3581                    }
 3582                }
 3583                {
 3584                    var awaiter = task13.GetAwaiter();
 3585                    if (awaiter.IsCompleted)
 3586                    {
 3587                        TryInvokeContinuationT13(this, awaiter);
 3588                    }
 3589                    else
 3590                    {
 3591                        awaiter.SourceOnCompleted(state =>
 3592                        {
 3593                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3594                            {
 3595                                TryInvokeContinuationT13(t.Item1, t.Item2);
 3596                            }
 3597                        }, StateTuple.Create(this, awaiter));
 3598                    }
 3599                }
 3600            }
 3601
 3602            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3603            {
 3604                try
 3605                {
 3606                    self.t1 = awaiter.GetResult();
 3607                }
 3608                catch (Exception ex)
 3609                {
 3610                    self.core.TrySetException(ex);
 3611                    return;
 3612                }
 3613
 3614                if (Interlocked.Increment(ref self.completedCount) == 13)
 3615                {
 3616                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3617                }
 3618            }
 3619
 3620            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3621            {
 3622                try
 3623                {
 3624                    self.t2 = awaiter.GetResult();
 3625                }
 3626                catch (Exception ex)
 3627                {
 3628                    self.core.TrySetException(ex);
 3629                    return;
 3630                }
 3631
 3632                if (Interlocked.Increment(ref self.completedCount) == 13)
 3633                {
 3634                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3635                }
 3636            }
 3637
 3638            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3639            {
 3640                try
 3641                {
 3642                    self.t3 = awaiter.GetResult();
 3643                }
 3644                catch (Exception ex)
 3645                {
 3646                    self.core.TrySetException(ex);
 3647                    return;
 3648                }
 3649
 3650                if (Interlocked.Increment(ref self.completedCount) == 13)
 3651                {
 3652                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3653                }
 3654            }
 3655
 3656            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3657            {
 3658                try
 3659                {
 3660                    self.t4 = awaiter.GetResult();
 3661                }
 3662                catch (Exception ex)
 3663                {
 3664                    self.core.TrySetException(ex);
 3665                    return;
 3666                }
 3667
 3668                if (Interlocked.Increment(ref self.completedCount) == 13)
 3669                {
 3670                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3671                }
 3672            }
 3673
 3674            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3675            {
 3676                try
 3677                {
 3678                    self.t5 = awaiter.GetResult();
 3679                }
 3680                catch (Exception ex)
 3681                {
 3682                    self.core.TrySetException(ex);
 3683                    return;
 3684                }
 3685
 3686                if (Interlocked.Increment(ref self.completedCount) == 13)
 3687                {
 3688                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3689                }
 3690            }
 3691
 3692            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3693            {
 3694                try
 3695                {
 3696                    self.t6 = awaiter.GetResult();
 3697                }
 3698                catch (Exception ex)
 3699                {
 3700                    self.core.TrySetException(ex);
 3701                    return;
 3702                }
 3703
 3704                if (Interlocked.Increment(ref self.completedCount) == 13)
 3705                {
 3706                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3707                }
 3708            }
 3709
 3710            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3711            {
 3712                try
 3713                {
 3714                    self.t7 = awaiter.GetResult();
 3715                }
 3716                catch (Exception ex)
 3717                {
 3718                    self.core.TrySetException(ex);
 3719                    return;
 3720                }
 3721
 3722                if (Interlocked.Increment(ref self.completedCount) == 13)
 3723                {
 3724                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3725                }
 3726            }
 3727
 3728            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3729            {
 3730                try
 3731                {
 3732                    self.t8 = awaiter.GetResult();
 3733                }
 3734                catch (Exception ex)
 3735                {
 3736                    self.core.TrySetException(ex);
 3737                    return;
 3738                }
 3739
 3740                if (Interlocked.Increment(ref self.completedCount) == 13)
 3741                {
 3742                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3743                }
 3744            }
 3745
 3746            static void TryInvokeContinuationT9(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3747            {
 3748                try
 3749                {
 3750                    self.t9 = awaiter.GetResult();
 3751                }
 3752                catch (Exception ex)
 3753                {
 3754                    self.core.TrySetException(ex);
 3755                    return;
 3756                }
 3757
 3758                if (Interlocked.Increment(ref self.completedCount) == 13)
 3759                {
 3760                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3761                }
 3762            }
 3763
 3764            static void TryInvokeContinuationT10(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3765            {
 3766                try
 3767                {
 3768                    self.t10 = awaiter.GetResult();
 3769                }
 3770                catch (Exception ex)
 3771                {
 3772                    self.core.TrySetException(ex);
 3773                    return;
 3774                }
 3775
 3776                if (Interlocked.Increment(ref self.completedCount) == 13)
 3777                {
 3778                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3779                }
 3780            }
 3781
 3782            static void TryInvokeContinuationT11(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3783            {
 3784                try
 3785                {
 3786                    self.t11 = awaiter.GetResult();
 3787                }
 3788                catch (Exception ex)
 3789                {
 3790                    self.core.TrySetException(ex);
 3791                    return;
 3792                }
 3793
 3794                if (Interlocked.Increment(ref self.completedCount) == 13)
 3795                {
 3796                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3797                }
 3798            }
 3799
 3800            static void TryInvokeContinuationT12(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3801            {
 3802                try
 3803                {
 3804                    self.t12 = awaiter.GetResult();
 3805                }
 3806                catch (Exception ex)
 3807                {
 3808                    self.core.TrySetException(ex);
 3809                    return;
 3810                }
 3811
 3812                if (Interlocked.Increment(ref self.completedCount) == 13)
 3813                {
 3814                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3815                }
 3816            }
 3817
 3818            static void TryInvokeContinuationT13(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3819            {
 3820                try
 3821                {
 3822                    self.t13 = awaiter.GetResult();
 3823                }
 3824                catch (Exception ex)
 3825                {
 3826                    self.core.TrySetException(ex);
 3827                    return;
 3828                }
 3829
 3830                if (Interlocked.Increment(ref self.completedCount) == 13)
 3831                {
 3832                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 3833                }
 3834            }
 3835
 3836
 3837            public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) GetResult(short token)
 3838            {
 3839                TaskTracker.RemoveTracking(this);
 3840                GC.SuppressFinalize(this);
 3841                return core.GetResult(token);
 3842            }
 3843
 3844            void IUniTaskSource.GetResult(short token)
 3845            {
 3846                GetResult(token);
 3847            }
 3848
 3849            public UniTaskStatus GetStatus(short token)
 3850            {
 3851                return core.GetStatus(token);
 3852            }
 3853
 3854            public UniTaskStatus UnsafeGetStatus()
 3855            {
 3856                return core.UnsafeGetStatus();
 3857            }
 3858
 3859            public void OnCompleted(Action<object> continuation, object state, short token)
 3860            {
 3861                core.OnCompleted(continuation, state, token);
 3862            }
 3863        }
 3864
 3865        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)> WhenAll<T1, T2, T3, T4, T5,
 03866        {
 03867            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 03868            {
 03869                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>((task1.GetAwaiter().Ge
 3870            }
 3871
 03872            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>(new WhenAllPromise<T1, T2,
 03873        }
 3874
 3875        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : IUniTaskSource<(T1, T
 3876        {
 3877            T1 t1 = default;
 3878            T2 t2 = default;
 3879            T3 t3 = default;
 3880            T4 t4 = default;
 3881            T5 t5 = default;
 3882            T6 t6 = default;
 3883            T7 t7 = default;
 3884            T8 t8 = default;
 3885            T9 t9 = default;
 3886            T10 t10 = default;
 3887            T11 t11 = default;
 3888            T12 t12 = default;
 3889            T13 t13 = default;
 3890            T14 t14 = default;
 3891            int completedCount;
 3892            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)> core;
 3893
 3894            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 3895            {
 3896                TaskTracker.TrackActiveTask(this, 3);
 3897
 3898                this.completedCount = 0;
 3899                {
 3900                    var awaiter = task1.GetAwaiter();
 3901                    if (awaiter.IsCompleted)
 3902                    {
 3903                        TryInvokeContinuationT1(this, awaiter);
 3904                    }
 3905                    else
 3906                    {
 3907                        awaiter.SourceOnCompleted(state =>
 3908                        {
 3909                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3910                            {
 3911                                TryInvokeContinuationT1(t.Item1, t.Item2);
 3912                            }
 3913                        }, StateTuple.Create(this, awaiter));
 3914                    }
 3915                }
 3916                {
 3917                    var awaiter = task2.GetAwaiter();
 3918                    if (awaiter.IsCompleted)
 3919                    {
 3920                        TryInvokeContinuationT2(this, awaiter);
 3921                    }
 3922                    else
 3923                    {
 3924                        awaiter.SourceOnCompleted(state =>
 3925                        {
 3926                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3927                            {
 3928                                TryInvokeContinuationT2(t.Item1, t.Item2);
 3929                            }
 3930                        }, StateTuple.Create(this, awaiter));
 3931                    }
 3932                }
 3933                {
 3934                    var awaiter = task3.GetAwaiter();
 3935                    if (awaiter.IsCompleted)
 3936                    {
 3937                        TryInvokeContinuationT3(this, awaiter);
 3938                    }
 3939                    else
 3940                    {
 3941                        awaiter.SourceOnCompleted(state =>
 3942                        {
 3943                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3944                            {
 3945                                TryInvokeContinuationT3(t.Item1, t.Item2);
 3946                            }
 3947                        }, StateTuple.Create(this, awaiter));
 3948                    }
 3949                }
 3950                {
 3951                    var awaiter = task4.GetAwaiter();
 3952                    if (awaiter.IsCompleted)
 3953                    {
 3954                        TryInvokeContinuationT4(this, awaiter);
 3955                    }
 3956                    else
 3957                    {
 3958                        awaiter.SourceOnCompleted(state =>
 3959                        {
 3960                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3961                            {
 3962                                TryInvokeContinuationT4(t.Item1, t.Item2);
 3963                            }
 3964                        }, StateTuple.Create(this, awaiter));
 3965                    }
 3966                }
 3967                {
 3968                    var awaiter = task5.GetAwaiter();
 3969                    if (awaiter.IsCompleted)
 3970                    {
 3971                        TryInvokeContinuationT5(this, awaiter);
 3972                    }
 3973                    else
 3974                    {
 3975                        awaiter.SourceOnCompleted(state =>
 3976                        {
 3977                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3978                            {
 3979                                TryInvokeContinuationT5(t.Item1, t.Item2);
 3980                            }
 3981                        }, StateTuple.Create(this, awaiter));
 3982                    }
 3983                }
 3984                {
 3985                    var awaiter = task6.GetAwaiter();
 3986                    if (awaiter.IsCompleted)
 3987                    {
 3988                        TryInvokeContinuationT6(this, awaiter);
 3989                    }
 3990                    else
 3991                    {
 3992                        awaiter.SourceOnCompleted(state =>
 3993                        {
 3994                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3995                            {
 3996                                TryInvokeContinuationT6(t.Item1, t.Item2);
 3997                            }
 3998                        }, StateTuple.Create(this, awaiter));
 3999                    }
 4000                }
 4001                {
 4002                    var awaiter = task7.GetAwaiter();
 4003                    if (awaiter.IsCompleted)
 4004                    {
 4005                        TryInvokeContinuationT7(this, awaiter);
 4006                    }
 4007                    else
 4008                    {
 4009                        awaiter.SourceOnCompleted(state =>
 4010                        {
 4011                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4012                            {
 4013                                TryInvokeContinuationT7(t.Item1, t.Item2);
 4014                            }
 4015                        }, StateTuple.Create(this, awaiter));
 4016                    }
 4017                }
 4018                {
 4019                    var awaiter = task8.GetAwaiter();
 4020                    if (awaiter.IsCompleted)
 4021                    {
 4022                        TryInvokeContinuationT8(this, awaiter);
 4023                    }
 4024                    else
 4025                    {
 4026                        awaiter.SourceOnCompleted(state =>
 4027                        {
 4028                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4029                            {
 4030                                TryInvokeContinuationT8(t.Item1, t.Item2);
 4031                            }
 4032                        }, StateTuple.Create(this, awaiter));
 4033                    }
 4034                }
 4035                {
 4036                    var awaiter = task9.GetAwaiter();
 4037                    if (awaiter.IsCompleted)
 4038                    {
 4039                        TryInvokeContinuationT9(this, awaiter);
 4040                    }
 4041                    else
 4042                    {
 4043                        awaiter.SourceOnCompleted(state =>
 4044                        {
 4045                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4046                            {
 4047                                TryInvokeContinuationT9(t.Item1, t.Item2);
 4048                            }
 4049                        }, StateTuple.Create(this, awaiter));
 4050                    }
 4051                }
 4052                {
 4053                    var awaiter = task10.GetAwaiter();
 4054                    if (awaiter.IsCompleted)
 4055                    {
 4056                        TryInvokeContinuationT10(this, awaiter);
 4057                    }
 4058                    else
 4059                    {
 4060                        awaiter.SourceOnCompleted(state =>
 4061                        {
 4062                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4063                            {
 4064                                TryInvokeContinuationT10(t.Item1, t.Item2);
 4065                            }
 4066                        }, StateTuple.Create(this, awaiter));
 4067                    }
 4068                }
 4069                {
 4070                    var awaiter = task11.GetAwaiter();
 4071                    if (awaiter.IsCompleted)
 4072                    {
 4073                        TryInvokeContinuationT11(this, awaiter);
 4074                    }
 4075                    else
 4076                    {
 4077                        awaiter.SourceOnCompleted(state =>
 4078                        {
 4079                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4080                            {
 4081                                TryInvokeContinuationT11(t.Item1, t.Item2);
 4082                            }
 4083                        }, StateTuple.Create(this, awaiter));
 4084                    }
 4085                }
 4086                {
 4087                    var awaiter = task12.GetAwaiter();
 4088                    if (awaiter.IsCompleted)
 4089                    {
 4090                        TryInvokeContinuationT12(this, awaiter);
 4091                    }
 4092                    else
 4093                    {
 4094                        awaiter.SourceOnCompleted(state =>
 4095                        {
 4096                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4097                            {
 4098                                TryInvokeContinuationT12(t.Item1, t.Item2);
 4099                            }
 4100                        }, StateTuple.Create(this, awaiter));
 4101                    }
 4102                }
 4103                {
 4104                    var awaiter = task13.GetAwaiter();
 4105                    if (awaiter.IsCompleted)
 4106                    {
 4107                        TryInvokeContinuationT13(this, awaiter);
 4108                    }
 4109                    else
 4110                    {
 4111                        awaiter.SourceOnCompleted(state =>
 4112                        {
 4113                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4114                            {
 4115                                TryInvokeContinuationT13(t.Item1, t.Item2);
 4116                            }
 4117                        }, StateTuple.Create(this, awaiter));
 4118                    }
 4119                }
 4120                {
 4121                    var awaiter = task14.GetAwaiter();
 4122                    if (awaiter.IsCompleted)
 4123                    {
 4124                        TryInvokeContinuationT14(this, awaiter);
 4125                    }
 4126                    else
 4127                    {
 4128                        awaiter.SourceOnCompleted(state =>
 4129                        {
 4130                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4131                            {
 4132                                TryInvokeContinuationT14(t.Item1, t.Item2);
 4133                            }
 4134                        }, StateTuple.Create(this, awaiter));
 4135                    }
 4136                }
 4137            }
 4138
 4139            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4140            {
 4141                try
 4142                {
 4143                    self.t1 = awaiter.GetResult();
 4144                }
 4145                catch (Exception ex)
 4146                {
 4147                    self.core.TrySetException(ex);
 4148                    return;
 4149                }
 4150
 4151                if (Interlocked.Increment(ref self.completedCount) == 14)
 4152                {
 4153                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4154                }
 4155            }
 4156
 4157            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4158            {
 4159                try
 4160                {
 4161                    self.t2 = awaiter.GetResult();
 4162                }
 4163                catch (Exception ex)
 4164                {
 4165                    self.core.TrySetException(ex);
 4166                    return;
 4167                }
 4168
 4169                if (Interlocked.Increment(ref self.completedCount) == 14)
 4170                {
 4171                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4172                }
 4173            }
 4174
 4175            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4176            {
 4177                try
 4178                {
 4179                    self.t3 = awaiter.GetResult();
 4180                }
 4181                catch (Exception ex)
 4182                {
 4183                    self.core.TrySetException(ex);
 4184                    return;
 4185                }
 4186
 4187                if (Interlocked.Increment(ref self.completedCount) == 14)
 4188                {
 4189                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4190                }
 4191            }
 4192
 4193            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4194            {
 4195                try
 4196                {
 4197                    self.t4 = awaiter.GetResult();
 4198                }
 4199                catch (Exception ex)
 4200                {
 4201                    self.core.TrySetException(ex);
 4202                    return;
 4203                }
 4204
 4205                if (Interlocked.Increment(ref self.completedCount) == 14)
 4206                {
 4207                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4208                }
 4209            }
 4210
 4211            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4212            {
 4213                try
 4214                {
 4215                    self.t5 = awaiter.GetResult();
 4216                }
 4217                catch (Exception ex)
 4218                {
 4219                    self.core.TrySetException(ex);
 4220                    return;
 4221                }
 4222
 4223                if (Interlocked.Increment(ref self.completedCount) == 14)
 4224                {
 4225                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4226                }
 4227            }
 4228
 4229            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4230            {
 4231                try
 4232                {
 4233                    self.t6 = awaiter.GetResult();
 4234                }
 4235                catch (Exception ex)
 4236                {
 4237                    self.core.TrySetException(ex);
 4238                    return;
 4239                }
 4240
 4241                if (Interlocked.Increment(ref self.completedCount) == 14)
 4242                {
 4243                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4244                }
 4245            }
 4246
 4247            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4248            {
 4249                try
 4250                {
 4251                    self.t7 = awaiter.GetResult();
 4252                }
 4253                catch (Exception ex)
 4254                {
 4255                    self.core.TrySetException(ex);
 4256                    return;
 4257                }
 4258
 4259                if (Interlocked.Increment(ref self.completedCount) == 14)
 4260                {
 4261                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4262                }
 4263            }
 4264
 4265            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4266            {
 4267                try
 4268                {
 4269                    self.t8 = awaiter.GetResult();
 4270                }
 4271                catch (Exception ex)
 4272                {
 4273                    self.core.TrySetException(ex);
 4274                    return;
 4275                }
 4276
 4277                if (Interlocked.Increment(ref self.completedCount) == 14)
 4278                {
 4279                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4280                }
 4281            }
 4282
 4283            static void TryInvokeContinuationT9(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4284            {
 4285                try
 4286                {
 4287                    self.t9 = awaiter.GetResult();
 4288                }
 4289                catch (Exception ex)
 4290                {
 4291                    self.core.TrySetException(ex);
 4292                    return;
 4293                }
 4294
 4295                if (Interlocked.Increment(ref self.completedCount) == 14)
 4296                {
 4297                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4298                }
 4299            }
 4300
 4301            static void TryInvokeContinuationT10(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4302            {
 4303                try
 4304                {
 4305                    self.t10 = awaiter.GetResult();
 4306                }
 4307                catch (Exception ex)
 4308                {
 4309                    self.core.TrySetException(ex);
 4310                    return;
 4311                }
 4312
 4313                if (Interlocked.Increment(ref self.completedCount) == 14)
 4314                {
 4315                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4316                }
 4317            }
 4318
 4319            static void TryInvokeContinuationT11(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4320            {
 4321                try
 4322                {
 4323                    self.t11 = awaiter.GetResult();
 4324                }
 4325                catch (Exception ex)
 4326                {
 4327                    self.core.TrySetException(ex);
 4328                    return;
 4329                }
 4330
 4331                if (Interlocked.Increment(ref self.completedCount) == 14)
 4332                {
 4333                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4334                }
 4335            }
 4336
 4337            static void TryInvokeContinuationT12(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4338            {
 4339                try
 4340                {
 4341                    self.t12 = awaiter.GetResult();
 4342                }
 4343                catch (Exception ex)
 4344                {
 4345                    self.core.TrySetException(ex);
 4346                    return;
 4347                }
 4348
 4349                if (Interlocked.Increment(ref self.completedCount) == 14)
 4350                {
 4351                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4352                }
 4353            }
 4354
 4355            static void TryInvokeContinuationT13(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4356            {
 4357                try
 4358                {
 4359                    self.t13 = awaiter.GetResult();
 4360                }
 4361                catch (Exception ex)
 4362                {
 4363                    self.core.TrySetException(ex);
 4364                    return;
 4365                }
 4366
 4367                if (Interlocked.Increment(ref self.completedCount) == 14)
 4368                {
 4369                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4370                }
 4371            }
 4372
 4373            static void TryInvokeContinuationT14(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4374            {
 4375                try
 4376                {
 4377                    self.t14 = awaiter.GetResult();
 4378                }
 4379                catch (Exception ex)
 4380                {
 4381                    self.core.TrySetException(ex);
 4382                    return;
 4383                }
 4384
 4385                if (Interlocked.Increment(ref self.completedCount) == 14)
 4386                {
 4387                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4388                }
 4389            }
 4390
 4391
 4392            public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) GetResult(short token)
 4393            {
 4394                TaskTracker.RemoveTracking(this);
 4395                GC.SuppressFinalize(this);
 4396                return core.GetResult(token);
 4397            }
 4398
 4399            void IUniTaskSource.GetResult(short token)
 4400            {
 4401                GetResult(token);
 4402            }
 4403
 4404            public UniTaskStatus GetStatus(short token)
 4405            {
 4406                return core.GetStatus(token);
 4407            }
 4408
 4409            public UniTaskStatus UnsafeGetStatus()
 4410            {
 4411                return core.UnsafeGetStatus();
 4412            }
 4413
 4414            public void OnCompleted(Action<object> continuation, object state, short token)
 4415            {
 4416                core.OnCompleted(continuation, state, token);
 4417            }
 4418        }
 4419
 4420        public static UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)> WhenAll<T1, T2, T3, T4
 04421        {
 04422            if (task1.Status.IsCompletedSuccessfully() && task2.Status.IsCompletedSuccessfully() && task3.Status.IsCompl
 04423            {
 04424                return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>((task1.GetAwaiter
 4425            }
 4426
 04427            return new UniTask<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>(new WhenAllPromise<T1
 04428        }
 4429
 4430        sealed class WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : IUniTaskSource<(
 4431        {
 4432            T1 t1 = default;
 4433            T2 t2 = default;
 4434            T3 t3 = default;
 4435            T4 t4 = default;
 4436            T5 t5 = default;
 4437            T6 t6 = default;
 4438            T7 t7 = default;
 4439            T8 t8 = default;
 4440            T9 t9 = default;
 4441            T10 t10 = default;
 4442            T11 t11 = default;
 4443            T12 t12 = default;
 4444            T13 t13 = default;
 4445            T14 t14 = default;
 4446            T15 t15 = default;
 4447            int completedCount;
 4448            UniTaskCompletionSourceCore<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)> core;
 4449
 4450            public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 4451            {
 4452                TaskTracker.TrackActiveTask(this, 3);
 4453
 4454                this.completedCount = 0;
 4455                {
 4456                    var awaiter = task1.GetAwaiter();
 4457                    if (awaiter.IsCompleted)
 4458                    {
 4459                        TryInvokeContinuationT1(this, awaiter);
 4460                    }
 4461                    else
 4462                    {
 4463                        awaiter.SourceOnCompleted(state =>
 4464                        {
 4465                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4466                            {
 4467                                TryInvokeContinuationT1(t.Item1, t.Item2);
 4468                            }
 4469                        }, StateTuple.Create(this, awaiter));
 4470                    }
 4471                }
 4472                {
 4473                    var awaiter = task2.GetAwaiter();
 4474                    if (awaiter.IsCompleted)
 4475                    {
 4476                        TryInvokeContinuationT2(this, awaiter);
 4477                    }
 4478                    else
 4479                    {
 4480                        awaiter.SourceOnCompleted(state =>
 4481                        {
 4482                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4483                            {
 4484                                TryInvokeContinuationT2(t.Item1, t.Item2);
 4485                            }
 4486                        }, StateTuple.Create(this, awaiter));
 4487                    }
 4488                }
 4489                {
 4490                    var awaiter = task3.GetAwaiter();
 4491                    if (awaiter.IsCompleted)
 4492                    {
 4493                        TryInvokeContinuationT3(this, awaiter);
 4494                    }
 4495                    else
 4496                    {
 4497                        awaiter.SourceOnCompleted(state =>
 4498                        {
 4499                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4500                            {
 4501                                TryInvokeContinuationT3(t.Item1, t.Item2);
 4502                            }
 4503                        }, StateTuple.Create(this, awaiter));
 4504                    }
 4505                }
 4506                {
 4507                    var awaiter = task4.GetAwaiter();
 4508                    if (awaiter.IsCompleted)
 4509                    {
 4510                        TryInvokeContinuationT4(this, awaiter);
 4511                    }
 4512                    else
 4513                    {
 4514                        awaiter.SourceOnCompleted(state =>
 4515                        {
 4516                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4517                            {
 4518                                TryInvokeContinuationT4(t.Item1, t.Item2);
 4519                            }
 4520                        }, StateTuple.Create(this, awaiter));
 4521                    }
 4522                }
 4523                {
 4524                    var awaiter = task5.GetAwaiter();
 4525                    if (awaiter.IsCompleted)
 4526                    {
 4527                        TryInvokeContinuationT5(this, awaiter);
 4528                    }
 4529                    else
 4530                    {
 4531                        awaiter.SourceOnCompleted(state =>
 4532                        {
 4533                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4534                            {
 4535                                TryInvokeContinuationT5(t.Item1, t.Item2);
 4536                            }
 4537                        }, StateTuple.Create(this, awaiter));
 4538                    }
 4539                }
 4540                {
 4541                    var awaiter = task6.GetAwaiter();
 4542                    if (awaiter.IsCompleted)
 4543                    {
 4544                        TryInvokeContinuationT6(this, awaiter);
 4545                    }
 4546                    else
 4547                    {
 4548                        awaiter.SourceOnCompleted(state =>
 4549                        {
 4550                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4551                            {
 4552                                TryInvokeContinuationT6(t.Item1, t.Item2);
 4553                            }
 4554                        }, StateTuple.Create(this, awaiter));
 4555                    }
 4556                }
 4557                {
 4558                    var awaiter = task7.GetAwaiter();
 4559                    if (awaiter.IsCompleted)
 4560                    {
 4561                        TryInvokeContinuationT7(this, awaiter);
 4562                    }
 4563                    else
 4564                    {
 4565                        awaiter.SourceOnCompleted(state =>
 4566                        {
 4567                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4568                            {
 4569                                TryInvokeContinuationT7(t.Item1, t.Item2);
 4570                            }
 4571                        }, StateTuple.Create(this, awaiter));
 4572                    }
 4573                }
 4574                {
 4575                    var awaiter = task8.GetAwaiter();
 4576                    if (awaiter.IsCompleted)
 4577                    {
 4578                        TryInvokeContinuationT8(this, awaiter);
 4579                    }
 4580                    else
 4581                    {
 4582                        awaiter.SourceOnCompleted(state =>
 4583                        {
 4584                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4585                            {
 4586                                TryInvokeContinuationT8(t.Item1, t.Item2);
 4587                            }
 4588                        }, StateTuple.Create(this, awaiter));
 4589                    }
 4590                }
 4591                {
 4592                    var awaiter = task9.GetAwaiter();
 4593                    if (awaiter.IsCompleted)
 4594                    {
 4595                        TryInvokeContinuationT9(this, awaiter);
 4596                    }
 4597                    else
 4598                    {
 4599                        awaiter.SourceOnCompleted(state =>
 4600                        {
 4601                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4602                            {
 4603                                TryInvokeContinuationT9(t.Item1, t.Item2);
 4604                            }
 4605                        }, StateTuple.Create(this, awaiter));
 4606                    }
 4607                }
 4608                {
 4609                    var awaiter = task10.GetAwaiter();
 4610                    if (awaiter.IsCompleted)
 4611                    {
 4612                        TryInvokeContinuationT10(this, awaiter);
 4613                    }
 4614                    else
 4615                    {
 4616                        awaiter.SourceOnCompleted(state =>
 4617                        {
 4618                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4619                            {
 4620                                TryInvokeContinuationT10(t.Item1, t.Item2);
 4621                            }
 4622                        }, StateTuple.Create(this, awaiter));
 4623                    }
 4624                }
 4625                {
 4626                    var awaiter = task11.GetAwaiter();
 4627                    if (awaiter.IsCompleted)
 4628                    {
 4629                        TryInvokeContinuationT11(this, awaiter);
 4630                    }
 4631                    else
 4632                    {
 4633                        awaiter.SourceOnCompleted(state =>
 4634                        {
 4635                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4636                            {
 4637                                TryInvokeContinuationT11(t.Item1, t.Item2);
 4638                            }
 4639                        }, StateTuple.Create(this, awaiter));
 4640                    }
 4641                }
 4642                {
 4643                    var awaiter = task12.GetAwaiter();
 4644                    if (awaiter.IsCompleted)
 4645                    {
 4646                        TryInvokeContinuationT12(this, awaiter);
 4647                    }
 4648                    else
 4649                    {
 4650                        awaiter.SourceOnCompleted(state =>
 4651                        {
 4652                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4653                            {
 4654                                TryInvokeContinuationT12(t.Item1, t.Item2);
 4655                            }
 4656                        }, StateTuple.Create(this, awaiter));
 4657                    }
 4658                }
 4659                {
 4660                    var awaiter = task13.GetAwaiter();
 4661                    if (awaiter.IsCompleted)
 4662                    {
 4663                        TryInvokeContinuationT13(this, awaiter);
 4664                    }
 4665                    else
 4666                    {
 4667                        awaiter.SourceOnCompleted(state =>
 4668                        {
 4669                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4670                            {
 4671                                TryInvokeContinuationT13(t.Item1, t.Item2);
 4672                            }
 4673                        }, StateTuple.Create(this, awaiter));
 4674                    }
 4675                }
 4676                {
 4677                    var awaiter = task14.GetAwaiter();
 4678                    if (awaiter.IsCompleted)
 4679                    {
 4680                        TryInvokeContinuationT14(this, awaiter);
 4681                    }
 4682                    else
 4683                    {
 4684                        awaiter.SourceOnCompleted(state =>
 4685                        {
 4686                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4687                            {
 4688                                TryInvokeContinuationT14(t.Item1, t.Item2);
 4689                            }
 4690                        }, StateTuple.Create(this, awaiter));
 4691                    }
 4692                }
 4693                {
 4694                    var awaiter = task15.GetAwaiter();
 4695                    if (awaiter.IsCompleted)
 4696                    {
 4697                        TryInvokeContinuationT15(this, awaiter);
 4698                    }
 4699                    else
 4700                    {
 4701                        awaiter.SourceOnCompleted(state =>
 4702                        {
 4703                            using (var t = (StateTuple<WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4704                            {
 4705                                TryInvokeContinuationT15(t.Item1, t.Item2);
 4706                            }
 4707                        }, StateTuple.Create(this, awaiter));
 4708                    }
 4709                }
 4710            }
 4711
 4712            static void TryInvokeContinuationT1(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4713            {
 4714                try
 4715                {
 4716                    self.t1 = awaiter.GetResult();
 4717                }
 4718                catch (Exception ex)
 4719                {
 4720                    self.core.TrySetException(ex);
 4721                    return;
 4722                }
 4723
 4724                if (Interlocked.Increment(ref self.completedCount) == 15)
 4725                {
 4726                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4727                }
 4728            }
 4729
 4730            static void TryInvokeContinuationT2(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4731            {
 4732                try
 4733                {
 4734                    self.t2 = awaiter.GetResult();
 4735                }
 4736                catch (Exception ex)
 4737                {
 4738                    self.core.TrySetException(ex);
 4739                    return;
 4740                }
 4741
 4742                if (Interlocked.Increment(ref self.completedCount) == 15)
 4743                {
 4744                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4745                }
 4746            }
 4747
 4748            static void TryInvokeContinuationT3(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4749            {
 4750                try
 4751                {
 4752                    self.t3 = awaiter.GetResult();
 4753                }
 4754                catch (Exception ex)
 4755                {
 4756                    self.core.TrySetException(ex);
 4757                    return;
 4758                }
 4759
 4760                if (Interlocked.Increment(ref self.completedCount) == 15)
 4761                {
 4762                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4763                }
 4764            }
 4765
 4766            static void TryInvokeContinuationT4(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4767            {
 4768                try
 4769                {
 4770                    self.t4 = awaiter.GetResult();
 4771                }
 4772                catch (Exception ex)
 4773                {
 4774                    self.core.TrySetException(ex);
 4775                    return;
 4776                }
 4777
 4778                if (Interlocked.Increment(ref self.completedCount) == 15)
 4779                {
 4780                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4781                }
 4782            }
 4783
 4784            static void TryInvokeContinuationT5(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4785            {
 4786                try
 4787                {
 4788                    self.t5 = awaiter.GetResult();
 4789                }
 4790                catch (Exception ex)
 4791                {
 4792                    self.core.TrySetException(ex);
 4793                    return;
 4794                }
 4795
 4796                if (Interlocked.Increment(ref self.completedCount) == 15)
 4797                {
 4798                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4799                }
 4800            }
 4801
 4802            static void TryInvokeContinuationT6(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4803            {
 4804                try
 4805                {
 4806                    self.t6 = awaiter.GetResult();
 4807                }
 4808                catch (Exception ex)
 4809                {
 4810                    self.core.TrySetException(ex);
 4811                    return;
 4812                }
 4813
 4814                if (Interlocked.Increment(ref self.completedCount) == 15)
 4815                {
 4816                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4817                }
 4818            }
 4819
 4820            static void TryInvokeContinuationT7(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4821            {
 4822                try
 4823                {
 4824                    self.t7 = awaiter.GetResult();
 4825                }
 4826                catch (Exception ex)
 4827                {
 4828                    self.core.TrySetException(ex);
 4829                    return;
 4830                }
 4831
 4832                if (Interlocked.Increment(ref self.completedCount) == 15)
 4833                {
 4834                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4835                }
 4836            }
 4837
 4838            static void TryInvokeContinuationT8(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4839            {
 4840                try
 4841                {
 4842                    self.t8 = awaiter.GetResult();
 4843                }
 4844                catch (Exception ex)
 4845                {
 4846                    self.core.TrySetException(ex);
 4847                    return;
 4848                }
 4849
 4850                if (Interlocked.Increment(ref self.completedCount) == 15)
 4851                {
 4852                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4853                }
 4854            }
 4855
 4856            static void TryInvokeContinuationT9(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4857            {
 4858                try
 4859                {
 4860                    self.t9 = awaiter.GetResult();
 4861                }
 4862                catch (Exception ex)
 4863                {
 4864                    self.core.TrySetException(ex);
 4865                    return;
 4866                }
 4867
 4868                if (Interlocked.Increment(ref self.completedCount) == 15)
 4869                {
 4870                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4871                }
 4872            }
 4873
 4874            static void TryInvokeContinuationT10(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4875            {
 4876                try
 4877                {
 4878                    self.t10 = awaiter.GetResult();
 4879                }
 4880                catch (Exception ex)
 4881                {
 4882                    self.core.TrySetException(ex);
 4883                    return;
 4884                }
 4885
 4886                if (Interlocked.Increment(ref self.completedCount) == 15)
 4887                {
 4888                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4889                }
 4890            }
 4891
 4892            static void TryInvokeContinuationT11(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4893            {
 4894                try
 4895                {
 4896                    self.t11 = awaiter.GetResult();
 4897                }
 4898                catch (Exception ex)
 4899                {
 4900                    self.core.TrySetException(ex);
 4901                    return;
 4902                }
 4903
 4904                if (Interlocked.Increment(ref self.completedCount) == 15)
 4905                {
 4906                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4907                }
 4908            }
 4909
 4910            static void TryInvokeContinuationT12(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4911            {
 4912                try
 4913                {
 4914                    self.t12 = awaiter.GetResult();
 4915                }
 4916                catch (Exception ex)
 4917                {
 4918                    self.core.TrySetException(ex);
 4919                    return;
 4920                }
 4921
 4922                if (Interlocked.Increment(ref self.completedCount) == 15)
 4923                {
 4924                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4925                }
 4926            }
 4927
 4928            static void TryInvokeContinuationT13(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4929            {
 4930                try
 4931                {
 4932                    self.t13 = awaiter.GetResult();
 4933                }
 4934                catch (Exception ex)
 4935                {
 4936                    self.core.TrySetException(ex);
 4937                    return;
 4938                }
 4939
 4940                if (Interlocked.Increment(ref self.completedCount) == 15)
 4941                {
 4942                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4943                }
 4944            }
 4945
 4946            static void TryInvokeContinuationT14(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4947            {
 4948                try
 4949                {
 4950                    self.t14 = awaiter.GetResult();
 4951                }
 4952                catch (Exception ex)
 4953                {
 4954                    self.core.TrySetException(ex);
 4955                    return;
 4956                }
 4957
 4958                if (Interlocked.Increment(ref self.completedCount) == 15)
 4959                {
 4960                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4961                }
 4962            }
 4963
 4964            static void TryInvokeContinuationT15(WhenAllPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4965            {
 4966                try
 4967                {
 4968                    self.t15 = awaiter.GetResult();
 4969                }
 4970                catch (Exception ex)
 4971                {
 4972                    self.core.TrySetException(ex);
 4973                    return;
 4974                }
 4975
 4976                if (Interlocked.Increment(ref self.completedCount) == 15)
 4977                {
 4978                    self.core.TrySetResult((self.t1, self.t2, self.t3, self.t4, self.t5, self.t6, self.t7, self.t8, self
 4979                }
 4980            }
 4981
 4982
 4983            public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) GetResult(short token)
 4984            {
 4985                TaskTracker.RemoveTracking(this);
 4986                GC.SuppressFinalize(this);
 4987                return core.GetResult(token);
 4988            }
 4989
 4990            void IUniTaskSource.GetResult(short token)
 4991            {
 4992                GetResult(token);
 4993            }
 4994
 4995            public UniTaskStatus GetStatus(short token)
 4996            {
 4997                return core.GetStatus(token);
 4998            }
 4999
 5000            public UniTaskStatus UnsafeGetStatus()
 5001            {
 5002                return core.UnsafeGetStatus();
 5003            }
 5004
 5005            public void OnCompleted(Action<object> continuation, object state, short token)
 5006            {
 5007                core.OnCompleted(continuation, state, token);
 5008            }
 5009        }
 5010    }
 5011}

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAny.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Threading;
 6using Cysharp.Threading.Tasks.Internal;
 7
 8namespace Cysharp.Threading.Tasks
 9{
 10    public partial struct UniTask
 11    {
 12        public static UniTask<(bool hasResultLeft, T result)> WhenAny<T>(UniTask<T> leftTask, UniTask rightTask)
 013        {
 014            return new UniTask<(bool, T)>(new WhenAnyLRPromise<T>(leftTask, rightTask), 0);
 015        }
 16
 17        public static UniTask<(int winArgumentIndex, T result)> WhenAny<T>(params UniTask<T>[] tasks)
 018        {
 019            return new UniTask<(int, T)>(new WhenAnyPromise<T>(tasks, tasks.Length), 0);
 020        }
 21
 22        public static UniTask<(int winArgumentIndex, T result)> WhenAny<T>(IEnumerable<UniTask<T>> tasks)
 023        {
 024            using (var span = ArrayPoolUtil.Materialize(tasks))
 025            {
 026                return new UniTask<(int, T)>(new WhenAnyPromise<T>(span.Array, span.Length), 0);
 27            }
 028        }
 29
 30        /// <summary>Return value is winArgumentIndex</summary>
 31        public static UniTask<int> WhenAny(params UniTask[] tasks)
 032        {
 033            return new UniTask<int>(new WhenAnyPromise(tasks, tasks.Length), 0);
 034        }
 35
 36        /// <summary>Return value is winArgumentIndex</summary>
 37        public static UniTask<int> WhenAny(IEnumerable<UniTask> tasks)
 038        {
 039            using (var span = ArrayPoolUtil.Materialize(tasks))
 040            {
 041                return new UniTask<int>(new WhenAnyPromise(span.Array, span.Length), 0);
 42            }
 043        }
 44
 45        sealed class WhenAnyLRPromise<T> : IUniTaskSource<(bool, T)>
 46        {
 47            int completedCount;
 48            UniTaskCompletionSourceCore<(bool, T)> core;
 49
 50            public WhenAnyLRPromise(UniTask<T> leftTask, UniTask rightTask)
 51            {
 52                TaskTracker.TrackActiveTask(this, 3);
 53
 54                {
 55                    UniTask<T>.Awaiter awaiter;
 56                    try
 57                    {
 58                        awaiter = leftTask.GetAwaiter();
 59                    }
 60                    catch (Exception ex)
 61                    {
 62                        core.TrySetException(ex);
 63                        goto RIGHT;
 64                    }
 65
 66                    if (awaiter.IsCompleted)
 67                    {
 68                        TryLeftInvokeContinuation(this, awaiter);
 69                    }
 70                    else
 71                    {
 72                        awaiter.SourceOnCompleted(state =>
 73                        {
 74                            using (var t = (StateTuple<WhenAnyLRPromise<T>, UniTask<T>.Awaiter>)state)
 75                            {
 76                                TryLeftInvokeContinuation(t.Item1, t.Item2);
 77                            }
 78                        }, StateTuple.Create(this, awaiter));
 79                    }
 80                }
 81                RIGHT:
 82                {
 83                    UniTask.Awaiter awaiter;
 84                    try
 85                    {
 86                        awaiter = rightTask.GetAwaiter();
 87                    }
 88                    catch (Exception ex)
 89                    {
 90                        core.TrySetException(ex);
 91                        return;
 92                    }
 93
 94                    if (awaiter.IsCompleted)
 95                    {
 96                        TryRightInvokeContinuation(this, awaiter);
 97                    }
 98                    else
 99                    {
 100                        awaiter.SourceOnCompleted(state =>
 101                        {
 102                            using (var t = (StateTuple<WhenAnyLRPromise<T>, UniTask.Awaiter>)state)
 103                            {
 104                                TryRightInvokeContinuation(t.Item1, t.Item2);
 105                            }
 106                        }, StateTuple.Create(this, awaiter));
 107                    }
 108                }
 109            }
 110
 111            static void TryLeftInvokeContinuation(WhenAnyLRPromise<T> self, in UniTask<T>.Awaiter awaiter)
 112            {
 113                T result;
 114                try
 115                {
 116                    result = awaiter.GetResult();
 117                }
 118                catch (Exception ex)
 119                {
 120                    self.core.TrySetException(ex);
 121                    return;
 122                }
 123
 124                if (Interlocked.Increment(ref self.completedCount) == 1)
 125                {
 126                    self.core.TrySetResult((true, result));
 127                }
 128            }
 129
 130            static void TryRightInvokeContinuation(WhenAnyLRPromise<T> self, in UniTask.Awaiter awaiter)
 131            {
 132                try
 133                {
 134                    awaiter.GetResult();
 135                }
 136                catch (Exception ex)
 137                {
 138                    self.core.TrySetException(ex);
 139                    return;
 140                }
 141
 142                if (Interlocked.Increment(ref self.completedCount) == 1)
 143                {
 144                    self.core.TrySetResult((false, default));
 145                }
 146            }
 147
 148            public (bool, T) GetResult(short token)
 149            {
 150                TaskTracker.RemoveTracking(this);
 151                GC.SuppressFinalize(this);
 152                return core.GetResult(token);
 153            }
 154
 155            public UniTaskStatus GetStatus(short token)
 156            {
 157                return core.GetStatus(token);
 158            }
 159
 160            public void OnCompleted(Action<object> continuation, object state, short token)
 161            {
 162                core.OnCompleted(continuation, state, token);
 163            }
 164
 165            public UniTaskStatus UnsafeGetStatus()
 166            {
 167                return core.UnsafeGetStatus();
 168            }
 169
 170            void IUniTaskSource.GetResult(short token)
 171            {
 172                GetResult(token);
 173            }
 174        }
 175
 176
 177        sealed class WhenAnyPromise<T> : IUniTaskSource<(int, T)>
 178        {
 179            int completedCount;
 180            UniTaskCompletionSourceCore<(int, T)> core;
 181
 182            public WhenAnyPromise(UniTask<T>[] tasks, int tasksLength)
 183            {
 184                if (tasksLength == 0)
 185                {
 186                    throw new ArgumentException("The tasks argument contains no tasks.");
 187                }
 188
 189                TaskTracker.TrackActiveTask(this, 3);
 190
 191                for (int i = 0; i < tasksLength; i++)
 192                {
 193                    UniTask<T>.Awaiter awaiter;
 194                    try
 195                    {
 196                        awaiter = tasks[i].GetAwaiter();
 197                    }
 198                    catch (Exception ex)
 199                    {
 200                        core.TrySetException(ex);
 201                        continue; // consume others.
 202                    }
 203
 204                    if (awaiter.IsCompleted)
 205                    {
 206                        TryInvokeContinuation(this, awaiter, i);
 207                    }
 208                    else
 209                    {
 210                        awaiter.SourceOnCompleted(state =>
 211                        {
 212                            using (var t = (StateTuple<WhenAnyPromise<T>, UniTask<T>.Awaiter, int>)state)
 213                            {
 214                                TryInvokeContinuation(t.Item1, t.Item2, t.Item3);
 215                            }
 216                        }, StateTuple.Create(this, awaiter, i));
 217                    }
 218                }
 219            }
 220
 221            static void TryInvokeContinuation(WhenAnyPromise<T> self, in UniTask<T>.Awaiter awaiter, int i)
 222            {
 223                T result;
 224                try
 225                {
 226                    result = awaiter.GetResult();
 227                }
 228                catch (Exception ex)
 229                {
 230                    self.core.TrySetException(ex);
 231                    return;
 232                }
 233
 234                if (Interlocked.Increment(ref self.completedCount) == 1)
 235                {
 236                    self.core.TrySetResult((i, result));
 237                }
 238            }
 239
 240            public (int, T) GetResult(short token)
 241            {
 242                TaskTracker.RemoveTracking(this);
 243                GC.SuppressFinalize(this);
 244                return core.GetResult(token);
 245            }
 246
 247            public UniTaskStatus GetStatus(short token)
 248            {
 249                return core.GetStatus(token);
 250            }
 251
 252            public void OnCompleted(Action<object> continuation, object state, short token)
 253            {
 254                core.OnCompleted(continuation, state, token);
 255            }
 256
 257            public UniTaskStatus UnsafeGetStatus()
 258            {
 259                return core.UnsafeGetStatus();
 260            }
 261
 262            void IUniTaskSource.GetResult(short token)
 263            {
 264                GetResult(token);
 265            }
 266        }
 267
 268        sealed class WhenAnyPromise : IUniTaskSource<int>
 269        {
 270            int completedCount;
 271            UniTaskCompletionSourceCore<int> core;
 272
 0273            public WhenAnyPromise(UniTask[] tasks, int tasksLength)
 0274            {
 0275                if (tasksLength == 0)
 0276                {
 0277                    throw new ArgumentException("The tasks argument contains no tasks.");
 278                }
 279
 0280                TaskTracker.TrackActiveTask(this, 3);
 281
 0282                for (int i = 0; i < tasksLength; i++)
 0283                {
 284                    UniTask.Awaiter awaiter;
 285                    try
 0286                    {
 0287                        awaiter = tasks[i].GetAwaiter();
 0288                    }
 0289                    catch (Exception ex)
 0290                    {
 0291                        core.TrySetException(ex);
 0292                        continue; // consume others.
 293                    }
 294
 0295                    if (awaiter.IsCompleted)
 0296                    {
 0297                        TryInvokeContinuation(this, awaiter, i);
 0298                    }
 299                    else
 0300                    {
 0301                        awaiter.SourceOnCompleted(state =>
 0302                        {
 0303                            using (var t = (StateTuple<WhenAnyPromise, UniTask.Awaiter, int>)state)
 0304                            {
 0305                                TryInvokeContinuation(t.Item1, t.Item2, t.Item3);
 0306                            }
 0307                        }, StateTuple.Create(this, awaiter, i));
 0308                    }
 0309                }
 0310            }
 311
 312            static void TryInvokeContinuation(WhenAnyPromise self, in UniTask.Awaiter awaiter, int i)
 0313            {
 314                try
 0315                {
 0316                    awaiter.GetResult();
 0317                }
 0318                catch (Exception ex)
 0319                {
 0320                    self.core.TrySetException(ex);
 0321                    return;
 322                }
 323
 0324                if (Interlocked.Increment(ref self.completedCount) == 1)
 0325                {
 0326                    self.core.TrySetResult(i);
 0327                }
 0328            }
 329
 330            public int GetResult(short token)
 0331            {
 0332                TaskTracker.RemoveTracking(this);
 0333                GC.SuppressFinalize(this);
 0334                return core.GetResult(token);
 0335            }
 336
 337            public UniTaskStatus GetStatus(short token)
 0338            {
 0339                return core.GetStatus(token);
 0340            }
 341
 342            public void OnCompleted(Action<object> continuation, object state, short token)
 0343            {
 0344                core.OnCompleted(continuation, state, token);
 0345            }
 346
 347            public UniTaskStatus UnsafeGetStatus()
 0348            {
 0349                return core.UnsafeGetStatus();
 0350            }
 351
 352            void IUniTaskSource.GetResult(short token)
 0353            {
 0354                GetResult(token);
 0355            }
 356        }
 357    }
 358}
 359

C:/Users/ahmet/FunradoCase/Assets/Plugins/UniTask/Runtime/UniTask.WhenAny.Generated.cs

#LineLine coverage
 1#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 2using System;
 3using System.Runtime.CompilerServices;
 4using System.Runtime.ExceptionServices;
 5using System.Threading;
 6using Cysharp.Threading.Tasks.Internal;
 7
 8namespace Cysharp.Threading.Tasks
 9{
 10    public partial struct UniTask
 11    {
 12        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2)> WhenAny<T1, T2>(UniTask<T1> task1, UniTask
 013        {
 014            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2)>(new WhenAnyPromise<T1, T2>(task1, task2),
 015        }
 16
 17        sealed class WhenAnyPromise<T1, T2> : IUniTaskSource<(int, T1 result1, T2 result2)>
 18        {
 19            int completedCount;
 20            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2)> core;
 21
 22            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2)
 23            {
 24                TaskTracker.TrackActiveTask(this, 3);
 25
 26                this.completedCount = 0;
 27                {
 28                    var awaiter = task1.GetAwaiter();
 29
 30                    if (awaiter.IsCompleted)
 31                    {
 32                        TryInvokeContinuationT1(this, awaiter);
 33                    }
 34                    else
 35                    {
 36                        awaiter.SourceOnCompleted(state =>
 37                        {
 38                            using (var t = (StateTuple<WhenAnyPromise<T1, T2>, UniTask<T1>.Awaiter>)state)
 39                            {
 40                                TryInvokeContinuationT1(t.Item1, t.Item2);
 41                            }
 42                        }, StateTuple.Create(this, awaiter));
 43                    }
 44                }
 45                {
 46                    var awaiter = task2.GetAwaiter();
 47
 48                    if (awaiter.IsCompleted)
 49                    {
 50                        TryInvokeContinuationT2(this, awaiter);
 51                    }
 52                    else
 53                    {
 54                        awaiter.SourceOnCompleted(state =>
 55                        {
 56                            using (var t = (StateTuple<WhenAnyPromise<T1, T2>, UniTask<T2>.Awaiter>)state)
 57                            {
 58                                TryInvokeContinuationT2(t.Item1, t.Item2);
 59                            }
 60                        }, StateTuple.Create(this, awaiter));
 61                    }
 62                }
 63            }
 64
 65            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2> self, in UniTask<T1>.Awaiter awaiter)
 66            {
 67                T1 result;
 68                try
 69                {
 70                    result = awaiter.GetResult();
 71                }
 72                catch (Exception ex)
 73                {
 74                    self.core.TrySetException(ex);
 75                    return;
 76                }
 77
 78                if (Interlocked.Increment(ref self.completedCount) == 1)
 79                {
 80                    self.core.TrySetResult((0, result, default));
 81                }
 82            }
 83
 84            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2> self, in UniTask<T2>.Awaiter awaiter)
 85            {
 86                T2 result;
 87                try
 88                {
 89                    result = awaiter.GetResult();
 90                }
 91                catch (Exception ex)
 92                {
 93                    self.core.TrySetException(ex);
 94                    return;
 95                }
 96
 97                if (Interlocked.Increment(ref self.completedCount) == 1)
 98                {
 99                    self.core.TrySetResult((1, default, result));
 100                }
 101            }
 102
 103
 104            public (int, T1 result1, T2 result2) GetResult(short token)
 105            {
 106                TaskTracker.RemoveTracking(this);
 107                GC.SuppressFinalize(this);
 108                return core.GetResult(token);
 109            }
 110
 111            public UniTaskStatus GetStatus(short token)
 112            {
 113                return core.GetStatus(token);
 114            }
 115
 116            public void OnCompleted(Action<object> continuation, object state, short token)
 117            {
 118                core.OnCompleted(continuation, state, token);
 119            }
 120
 121            public UniTaskStatus UnsafeGetStatus()
 122            {
 123                return core.UnsafeGetStatus();
 124            }
 125
 126            void IUniTaskSource.GetResult(short token)
 127            {
 128                GetResult(token);
 129            }
 130        }
 131
 132        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3)> WhenAny<T1, T2, T3>(UniTask<T1
 0133        {
 0134            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3)>(new WhenAnyPromise<T1, T2, T3
 0135        }
 136
 137        sealed class WhenAnyPromise<T1, T2, T3> : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3)>
 138        {
 139            int completedCount;
 140            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3)> core;
 141
 142            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3)
 143            {
 144                TaskTracker.TrackActiveTask(this, 3);
 145
 146                this.completedCount = 0;
 147                {
 148                    var awaiter = task1.GetAwaiter();
 149
 150                    if (awaiter.IsCompleted)
 151                    {
 152                        TryInvokeContinuationT1(this, awaiter);
 153                    }
 154                    else
 155                    {
 156                        awaiter.SourceOnCompleted(state =>
 157                        {
 158                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3>, UniTask<T1>.Awaiter>)state)
 159                            {
 160                                TryInvokeContinuationT1(t.Item1, t.Item2);
 161                            }
 162                        }, StateTuple.Create(this, awaiter));
 163                    }
 164                }
 165                {
 166                    var awaiter = task2.GetAwaiter();
 167
 168                    if (awaiter.IsCompleted)
 169                    {
 170                        TryInvokeContinuationT2(this, awaiter);
 171                    }
 172                    else
 173                    {
 174                        awaiter.SourceOnCompleted(state =>
 175                        {
 176                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3>, UniTask<T2>.Awaiter>)state)
 177                            {
 178                                TryInvokeContinuationT2(t.Item1, t.Item2);
 179                            }
 180                        }, StateTuple.Create(this, awaiter));
 181                    }
 182                }
 183                {
 184                    var awaiter = task3.GetAwaiter();
 185
 186                    if (awaiter.IsCompleted)
 187                    {
 188                        TryInvokeContinuationT3(this, awaiter);
 189                    }
 190                    else
 191                    {
 192                        awaiter.SourceOnCompleted(state =>
 193                        {
 194                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3>, UniTask<T3>.Awaiter>)state)
 195                            {
 196                                TryInvokeContinuationT3(t.Item1, t.Item2);
 197                            }
 198                        }, StateTuple.Create(this, awaiter));
 199                    }
 200                }
 201            }
 202
 203            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3> self, in UniTask<T1>.Awaiter awaiter)
 204            {
 205                T1 result;
 206                try
 207                {
 208                    result = awaiter.GetResult();
 209                }
 210                catch (Exception ex)
 211                {
 212                    self.core.TrySetException(ex);
 213                    return;
 214                }
 215
 216                if (Interlocked.Increment(ref self.completedCount) == 1)
 217                {
 218                    self.core.TrySetResult((0, result, default, default));
 219                }
 220            }
 221
 222            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3> self, in UniTask<T2>.Awaiter awaiter)
 223            {
 224                T2 result;
 225                try
 226                {
 227                    result = awaiter.GetResult();
 228                }
 229                catch (Exception ex)
 230                {
 231                    self.core.TrySetException(ex);
 232                    return;
 233                }
 234
 235                if (Interlocked.Increment(ref self.completedCount) == 1)
 236                {
 237                    self.core.TrySetResult((1, default, result, default));
 238                }
 239            }
 240
 241            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3> self, in UniTask<T3>.Awaiter awaiter)
 242            {
 243                T3 result;
 244                try
 245                {
 246                    result = awaiter.GetResult();
 247                }
 248                catch (Exception ex)
 249                {
 250                    self.core.TrySetException(ex);
 251                    return;
 252                }
 253
 254                if (Interlocked.Increment(ref self.completedCount) == 1)
 255                {
 256                    self.core.TrySetResult((2, default, default, result));
 257                }
 258            }
 259
 260
 261            public (int, T1 result1, T2 result2, T3 result3) GetResult(short token)
 262            {
 263                TaskTracker.RemoveTracking(this);
 264                GC.SuppressFinalize(this);
 265                return core.GetResult(token);
 266            }
 267
 268            public UniTaskStatus GetStatus(short token)
 269            {
 270                return core.GetStatus(token);
 271            }
 272
 273            public void OnCompleted(Action<object> continuation, object state, short token)
 274            {
 275                core.OnCompleted(continuation, state, token);
 276            }
 277
 278            public UniTaskStatus UnsafeGetStatus()
 279            {
 280                return core.UnsafeGetStatus();
 281            }
 282
 283            void IUniTaskSource.GetResult(short token)
 284            {
 285                GetResult(token);
 286            }
 287        }
 288
 289        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4)> WhenAny<T1, T2, T3
 0290        {
 0291            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4)>(new WhenAnyPromis
 0292        }
 293
 294        sealed class WhenAnyPromise<T1, T2, T3, T4> : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 result
 295        {
 296            int completedCount;
 297            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4)> core;
 298
 299            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4)
 300            {
 301                TaskTracker.TrackActiveTask(this, 3);
 302
 303                this.completedCount = 0;
 304                {
 305                    var awaiter = task1.GetAwaiter();
 306
 307                    if (awaiter.IsCompleted)
 308                    {
 309                        TryInvokeContinuationT1(this, awaiter);
 310                    }
 311                    else
 312                    {
 313                        awaiter.SourceOnCompleted(state =>
 314                        {
 315                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T1>.Awaiter>)state)
 316                            {
 317                                TryInvokeContinuationT1(t.Item1, t.Item2);
 318                            }
 319                        }, StateTuple.Create(this, awaiter));
 320                    }
 321                }
 322                {
 323                    var awaiter = task2.GetAwaiter();
 324
 325                    if (awaiter.IsCompleted)
 326                    {
 327                        TryInvokeContinuationT2(this, awaiter);
 328                    }
 329                    else
 330                    {
 331                        awaiter.SourceOnCompleted(state =>
 332                        {
 333                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T2>.Awaiter>)state)
 334                            {
 335                                TryInvokeContinuationT2(t.Item1, t.Item2);
 336                            }
 337                        }, StateTuple.Create(this, awaiter));
 338                    }
 339                }
 340                {
 341                    var awaiter = task3.GetAwaiter();
 342
 343                    if (awaiter.IsCompleted)
 344                    {
 345                        TryInvokeContinuationT3(this, awaiter);
 346                    }
 347                    else
 348                    {
 349                        awaiter.SourceOnCompleted(state =>
 350                        {
 351                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T3>.Awaiter>)state)
 352                            {
 353                                TryInvokeContinuationT3(t.Item1, t.Item2);
 354                            }
 355                        }, StateTuple.Create(this, awaiter));
 356                    }
 357                }
 358                {
 359                    var awaiter = task4.GetAwaiter();
 360
 361                    if (awaiter.IsCompleted)
 362                    {
 363                        TryInvokeContinuationT4(this, awaiter);
 364                    }
 365                    else
 366                    {
 367                        awaiter.SourceOnCompleted(state =>
 368                        {
 369                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4>, UniTask<T4>.Awaiter>)state)
 370                            {
 371                                TryInvokeContinuationT4(t.Item1, t.Item2);
 372                            }
 373                        }, StateTuple.Create(this, awaiter));
 374                    }
 375                }
 376            }
 377
 378            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T1>.Awaiter awaiter)
 379            {
 380                T1 result;
 381                try
 382                {
 383                    result = awaiter.GetResult();
 384                }
 385                catch (Exception ex)
 386                {
 387                    self.core.TrySetException(ex);
 388                    return;
 389                }
 390
 391                if (Interlocked.Increment(ref self.completedCount) == 1)
 392                {
 393                    self.core.TrySetResult((0, result, default, default, default));
 394                }
 395            }
 396
 397            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T2>.Awaiter awaiter)
 398            {
 399                T2 result;
 400                try
 401                {
 402                    result = awaiter.GetResult();
 403                }
 404                catch (Exception ex)
 405                {
 406                    self.core.TrySetException(ex);
 407                    return;
 408                }
 409
 410                if (Interlocked.Increment(ref self.completedCount) == 1)
 411                {
 412                    self.core.TrySetResult((1, default, result, default, default));
 413                }
 414            }
 415
 416            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T3>.Awaiter awaiter)
 417            {
 418                T3 result;
 419                try
 420                {
 421                    result = awaiter.GetResult();
 422                }
 423                catch (Exception ex)
 424                {
 425                    self.core.TrySetException(ex);
 426                    return;
 427                }
 428
 429                if (Interlocked.Increment(ref self.completedCount) == 1)
 430                {
 431                    self.core.TrySetResult((2, default, default, result, default));
 432                }
 433            }
 434
 435            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4> self, in UniTask<T4>.Awaiter awaiter)
 436            {
 437                T4 result;
 438                try
 439                {
 440                    result = awaiter.GetResult();
 441                }
 442                catch (Exception ex)
 443                {
 444                    self.core.TrySetException(ex);
 445                    return;
 446                }
 447
 448                if (Interlocked.Increment(ref self.completedCount) == 1)
 449                {
 450                    self.core.TrySetResult((3, default, default, default, result));
 451                }
 452            }
 453
 454
 455            public (int, T1 result1, T2 result2, T3 result3, T4 result4) GetResult(short token)
 456            {
 457                TaskTracker.RemoveTracking(this);
 458                GC.SuppressFinalize(this);
 459                return core.GetResult(token);
 460            }
 461
 462            public UniTaskStatus GetStatus(short token)
 463            {
 464                return core.GetStatus(token);
 465            }
 466
 467            public void OnCompleted(Action<object> continuation, object state, short token)
 468            {
 469                core.OnCompleted(continuation, state, token);
 470            }
 471
 472            public UniTaskStatus UnsafeGetStatus()
 473            {
 474                return core.UnsafeGetStatus();
 475            }
 476
 477            void IUniTaskSource.GetResult(short token)
 478            {
 479                GetResult(token);
 480            }
 481        }
 482
 483        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)> WhenAn
 0484        {
 0485            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)>(new W
 0486        }
 487
 488        sealed class WhenAnyPromise<T1, T2, T3, T4, T5> : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T4 re
 489        {
 490            int completedCount;
 491            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)> core;
 492
 493            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 494            {
 495                TaskTracker.TrackActiveTask(this, 3);
 496
 497                this.completedCount = 0;
 498                {
 499                    var awaiter = task1.GetAwaiter();
 500
 501                    if (awaiter.IsCompleted)
 502                    {
 503                        TryInvokeContinuationT1(this, awaiter);
 504                    }
 505                    else
 506                    {
 507                        awaiter.SourceOnCompleted(state =>
 508                        {
 509                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T1>.Awaiter>)state)
 510                            {
 511                                TryInvokeContinuationT1(t.Item1, t.Item2);
 512                            }
 513                        }, StateTuple.Create(this, awaiter));
 514                    }
 515                }
 516                {
 517                    var awaiter = task2.GetAwaiter();
 518
 519                    if (awaiter.IsCompleted)
 520                    {
 521                        TryInvokeContinuationT2(this, awaiter);
 522                    }
 523                    else
 524                    {
 525                        awaiter.SourceOnCompleted(state =>
 526                        {
 527                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T2>.Awaiter>)state)
 528                            {
 529                                TryInvokeContinuationT2(t.Item1, t.Item2);
 530                            }
 531                        }, StateTuple.Create(this, awaiter));
 532                    }
 533                }
 534                {
 535                    var awaiter = task3.GetAwaiter();
 536
 537                    if (awaiter.IsCompleted)
 538                    {
 539                        TryInvokeContinuationT3(this, awaiter);
 540                    }
 541                    else
 542                    {
 543                        awaiter.SourceOnCompleted(state =>
 544                        {
 545                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T3>.Awaiter>)state)
 546                            {
 547                                TryInvokeContinuationT3(t.Item1, t.Item2);
 548                            }
 549                        }, StateTuple.Create(this, awaiter));
 550                    }
 551                }
 552                {
 553                    var awaiter = task4.GetAwaiter();
 554
 555                    if (awaiter.IsCompleted)
 556                    {
 557                        TryInvokeContinuationT4(this, awaiter);
 558                    }
 559                    else
 560                    {
 561                        awaiter.SourceOnCompleted(state =>
 562                        {
 563                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T4>.Awaiter>)state)
 564                            {
 565                                TryInvokeContinuationT4(t.Item1, t.Item2);
 566                            }
 567                        }, StateTuple.Create(this, awaiter));
 568                    }
 569                }
 570                {
 571                    var awaiter = task5.GetAwaiter();
 572
 573                    if (awaiter.IsCompleted)
 574                    {
 575                        TryInvokeContinuationT5(this, awaiter);
 576                    }
 577                    else
 578                    {
 579                        awaiter.SourceOnCompleted(state =>
 580                        {
 581                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5>, UniTask<T5>.Awaiter>)state)
 582                            {
 583                                TryInvokeContinuationT5(t.Item1, t.Item2);
 584                            }
 585                        }, StateTuple.Create(this, awaiter));
 586                    }
 587                }
 588            }
 589
 590            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T1>.Awaiter awaiter)
 591            {
 592                T1 result;
 593                try
 594                {
 595                    result = awaiter.GetResult();
 596                }
 597                catch (Exception ex)
 598                {
 599                    self.core.TrySetException(ex);
 600                    return;
 601                }
 602
 603                if (Interlocked.Increment(ref self.completedCount) == 1)
 604                {
 605                    self.core.TrySetResult((0, result, default, default, default, default));
 606                }
 607            }
 608
 609            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T2>.Awaiter awaiter)
 610            {
 611                T2 result;
 612                try
 613                {
 614                    result = awaiter.GetResult();
 615                }
 616                catch (Exception ex)
 617                {
 618                    self.core.TrySetException(ex);
 619                    return;
 620                }
 621
 622                if (Interlocked.Increment(ref self.completedCount) == 1)
 623                {
 624                    self.core.TrySetResult((1, default, result, default, default, default));
 625                }
 626            }
 627
 628            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T3>.Awaiter awaiter)
 629            {
 630                T3 result;
 631                try
 632                {
 633                    result = awaiter.GetResult();
 634                }
 635                catch (Exception ex)
 636                {
 637                    self.core.TrySetException(ex);
 638                    return;
 639                }
 640
 641                if (Interlocked.Increment(ref self.completedCount) == 1)
 642                {
 643                    self.core.TrySetResult((2, default, default, result, default, default));
 644                }
 645            }
 646
 647            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T4>.Awaiter awaiter)
 648            {
 649                T4 result;
 650                try
 651                {
 652                    result = awaiter.GetResult();
 653                }
 654                catch (Exception ex)
 655                {
 656                    self.core.TrySetException(ex);
 657                    return;
 658                }
 659
 660                if (Interlocked.Increment(ref self.completedCount) == 1)
 661                {
 662                    self.core.TrySetResult((3, default, default, default, result, default));
 663                }
 664            }
 665
 666            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5> self, in UniTask<T5>.Awaiter awaiter)
 667            {
 668                T5 result;
 669                try
 670                {
 671                    result = awaiter.GetResult();
 672                }
 673                catch (Exception ex)
 674                {
 675                    self.core.TrySetException(ex);
 676                    return;
 677                }
 678
 679                if (Interlocked.Increment(ref self.completedCount) == 1)
 680                {
 681                    self.core.TrySetResult((4, default, default, default, default, result));
 682                }
 683            }
 684
 685
 686            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5) GetResult(short token)
 687            {
 688                TaskTracker.RemoveTracking(this);
 689                GC.SuppressFinalize(this);
 690                return core.GetResult(token);
 691            }
 692
 693            public UniTaskStatus GetStatus(short token)
 694            {
 695                return core.GetStatus(token);
 696            }
 697
 698            public void OnCompleted(Action<object> continuation, object state, short token)
 699            {
 700                core.OnCompleted(continuation, state, token);
 701            }
 702
 703            public UniTaskStatus UnsafeGetStatus()
 704            {
 705                return core.UnsafeGetStatus();
 706            }
 707
 708            void IUniTaskSource.GetResult(short token)
 709            {
 710                GetResult(token);
 711            }
 712        }
 713
 714        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 0715        {
 0716            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 0717        }
 718
 719        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6> : IUniTaskSource<(int, T1 result1, T2 result2, T3 result3, T
 720        {
 721            int completedCount;
 722            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6)> c
 723
 724            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 725            {
 726                TaskTracker.TrackActiveTask(this, 3);
 727
 728                this.completedCount = 0;
 729                {
 730                    var awaiter = task1.GetAwaiter();
 731
 732                    if (awaiter.IsCompleted)
 733                    {
 734                        TryInvokeContinuationT1(this, awaiter);
 735                    }
 736                    else
 737                    {
 738                        awaiter.SourceOnCompleted(state =>
 739                        {
 740                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T1>.Awaiter>)stat
 741                            {
 742                                TryInvokeContinuationT1(t.Item1, t.Item2);
 743                            }
 744                        }, StateTuple.Create(this, awaiter));
 745                    }
 746                }
 747                {
 748                    var awaiter = task2.GetAwaiter();
 749
 750                    if (awaiter.IsCompleted)
 751                    {
 752                        TryInvokeContinuationT2(this, awaiter);
 753                    }
 754                    else
 755                    {
 756                        awaiter.SourceOnCompleted(state =>
 757                        {
 758                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T2>.Awaiter>)stat
 759                            {
 760                                TryInvokeContinuationT2(t.Item1, t.Item2);
 761                            }
 762                        }, StateTuple.Create(this, awaiter));
 763                    }
 764                }
 765                {
 766                    var awaiter = task3.GetAwaiter();
 767
 768                    if (awaiter.IsCompleted)
 769                    {
 770                        TryInvokeContinuationT3(this, awaiter);
 771                    }
 772                    else
 773                    {
 774                        awaiter.SourceOnCompleted(state =>
 775                        {
 776                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T3>.Awaiter>)stat
 777                            {
 778                                TryInvokeContinuationT3(t.Item1, t.Item2);
 779                            }
 780                        }, StateTuple.Create(this, awaiter));
 781                    }
 782                }
 783                {
 784                    var awaiter = task4.GetAwaiter();
 785
 786                    if (awaiter.IsCompleted)
 787                    {
 788                        TryInvokeContinuationT4(this, awaiter);
 789                    }
 790                    else
 791                    {
 792                        awaiter.SourceOnCompleted(state =>
 793                        {
 794                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T4>.Awaiter>)stat
 795                            {
 796                                TryInvokeContinuationT4(t.Item1, t.Item2);
 797                            }
 798                        }, StateTuple.Create(this, awaiter));
 799                    }
 800                }
 801                {
 802                    var awaiter = task5.GetAwaiter();
 803
 804                    if (awaiter.IsCompleted)
 805                    {
 806                        TryInvokeContinuationT5(this, awaiter);
 807                    }
 808                    else
 809                    {
 810                        awaiter.SourceOnCompleted(state =>
 811                        {
 812                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T5>.Awaiter>)stat
 813                            {
 814                                TryInvokeContinuationT5(t.Item1, t.Item2);
 815                            }
 816                        }, StateTuple.Create(this, awaiter));
 817                    }
 818                }
 819                {
 820                    var awaiter = task6.GetAwaiter();
 821
 822                    if (awaiter.IsCompleted)
 823                    {
 824                        TryInvokeContinuationT6(this, awaiter);
 825                    }
 826                    else
 827                    {
 828                        awaiter.SourceOnCompleted(state =>
 829                        {
 830                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6>, UniTask<T6>.Awaiter>)stat
 831                            {
 832                                TryInvokeContinuationT6(t.Item1, t.Item2);
 833                            }
 834                        }, StateTuple.Create(this, awaiter));
 835                    }
 836                }
 837            }
 838
 839            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T1>.Awaiter awai
 840            {
 841                T1 result;
 842                try
 843                {
 844                    result = awaiter.GetResult();
 845                }
 846                catch (Exception ex)
 847                {
 848                    self.core.TrySetException(ex);
 849                    return;
 850                }
 851
 852                if (Interlocked.Increment(ref self.completedCount) == 1)
 853                {
 854                    self.core.TrySetResult((0, result, default, default, default, default, default));
 855                }
 856            }
 857
 858            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T2>.Awaiter awai
 859            {
 860                T2 result;
 861                try
 862                {
 863                    result = awaiter.GetResult();
 864                }
 865                catch (Exception ex)
 866                {
 867                    self.core.TrySetException(ex);
 868                    return;
 869                }
 870
 871                if (Interlocked.Increment(ref self.completedCount) == 1)
 872                {
 873                    self.core.TrySetResult((1, default, result, default, default, default, default));
 874                }
 875            }
 876
 877            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T3>.Awaiter awai
 878            {
 879                T3 result;
 880                try
 881                {
 882                    result = awaiter.GetResult();
 883                }
 884                catch (Exception ex)
 885                {
 886                    self.core.TrySetException(ex);
 887                    return;
 888                }
 889
 890                if (Interlocked.Increment(ref self.completedCount) == 1)
 891                {
 892                    self.core.TrySetResult((2, default, default, result, default, default, default));
 893                }
 894            }
 895
 896            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T4>.Awaiter awai
 897            {
 898                T4 result;
 899                try
 900                {
 901                    result = awaiter.GetResult();
 902                }
 903                catch (Exception ex)
 904                {
 905                    self.core.TrySetException(ex);
 906                    return;
 907                }
 908
 909                if (Interlocked.Increment(ref self.completedCount) == 1)
 910                {
 911                    self.core.TrySetResult((3, default, default, default, result, default, default));
 912                }
 913            }
 914
 915            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T5>.Awaiter awai
 916            {
 917                T5 result;
 918                try
 919                {
 920                    result = awaiter.GetResult();
 921                }
 922                catch (Exception ex)
 923                {
 924                    self.core.TrySetException(ex);
 925                    return;
 926                }
 927
 928                if (Interlocked.Increment(ref self.completedCount) == 1)
 929                {
 930                    self.core.TrySetResult((4, default, default, default, default, result, default));
 931                }
 932            }
 933
 934            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6> self, in UniTask<T6>.Awaiter awai
 935            {
 936                T6 result;
 937                try
 938                {
 939                    result = awaiter.GetResult();
 940                }
 941                catch (Exception ex)
 942                {
 943                    self.core.TrySetException(ex);
 944                    return;
 945                }
 946
 947                if (Interlocked.Increment(ref self.completedCount) == 1)
 948                {
 949                    self.core.TrySetResult((5, default, default, default, default, default, result));
 950                }
 951            }
 952
 953
 954            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6) GetResult(short token)
 955            {
 956                TaskTracker.RemoveTracking(this);
 957                GC.SuppressFinalize(this);
 958                return core.GetResult(token);
 959            }
 960
 961            public UniTaskStatus GetStatus(short token)
 962            {
 963                return core.GetStatus(token);
 964            }
 965
 966            public void OnCompleted(Action<object> continuation, object state, short token)
 967            {
 968                core.OnCompleted(continuation, state, token);
 969            }
 970
 971            public UniTaskStatus UnsafeGetStatus()
 972            {
 973                return core.UnsafeGetStatus();
 974            }
 975
 976            void IUniTaskSource.GetResult(short token)
 977            {
 978                GetResult(token);
 979            }
 980        }
 981
 982        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 0983        {
 0984            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 0985        }
 986
 987        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> : IUniTaskSource<(int, T1 result1, T2 result2, T3 result
 988        {
 989            int completedCount;
 990            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 991
 992            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 993            {
 994                TaskTracker.TrackActiveTask(this, 3);
 995
 996                this.completedCount = 0;
 997                {
 998                    var awaiter = task1.GetAwaiter();
 999
 1000                    if (awaiter.IsCompleted)
 1001                    {
 1002                        TryInvokeContinuationT1(this, awaiter);
 1003                    }
 1004                    else
 1005                    {
 1006                        awaiter.SourceOnCompleted(state =>
 1007                        {
 1008                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T1>.Awaiter>)
 1009                            {
 1010                                TryInvokeContinuationT1(t.Item1, t.Item2);
 1011                            }
 1012                        }, StateTuple.Create(this, awaiter));
 1013                    }
 1014                }
 1015                {
 1016                    var awaiter = task2.GetAwaiter();
 1017
 1018                    if (awaiter.IsCompleted)
 1019                    {
 1020                        TryInvokeContinuationT2(this, awaiter);
 1021                    }
 1022                    else
 1023                    {
 1024                        awaiter.SourceOnCompleted(state =>
 1025                        {
 1026                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T2>.Awaiter>)
 1027                            {
 1028                                TryInvokeContinuationT2(t.Item1, t.Item2);
 1029                            }
 1030                        }, StateTuple.Create(this, awaiter));
 1031                    }
 1032                }
 1033                {
 1034                    var awaiter = task3.GetAwaiter();
 1035
 1036                    if (awaiter.IsCompleted)
 1037                    {
 1038                        TryInvokeContinuationT3(this, awaiter);
 1039                    }
 1040                    else
 1041                    {
 1042                        awaiter.SourceOnCompleted(state =>
 1043                        {
 1044                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T3>.Awaiter>)
 1045                            {
 1046                                TryInvokeContinuationT3(t.Item1, t.Item2);
 1047                            }
 1048                        }, StateTuple.Create(this, awaiter));
 1049                    }
 1050                }
 1051                {
 1052                    var awaiter = task4.GetAwaiter();
 1053
 1054                    if (awaiter.IsCompleted)
 1055                    {
 1056                        TryInvokeContinuationT4(this, awaiter);
 1057                    }
 1058                    else
 1059                    {
 1060                        awaiter.SourceOnCompleted(state =>
 1061                        {
 1062                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T4>.Awaiter>)
 1063                            {
 1064                                TryInvokeContinuationT4(t.Item1, t.Item2);
 1065                            }
 1066                        }, StateTuple.Create(this, awaiter));
 1067                    }
 1068                }
 1069                {
 1070                    var awaiter = task5.GetAwaiter();
 1071
 1072                    if (awaiter.IsCompleted)
 1073                    {
 1074                        TryInvokeContinuationT5(this, awaiter);
 1075                    }
 1076                    else
 1077                    {
 1078                        awaiter.SourceOnCompleted(state =>
 1079                        {
 1080                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T5>.Awaiter>)
 1081                            {
 1082                                TryInvokeContinuationT5(t.Item1, t.Item2);
 1083                            }
 1084                        }, StateTuple.Create(this, awaiter));
 1085                    }
 1086                }
 1087                {
 1088                    var awaiter = task6.GetAwaiter();
 1089
 1090                    if (awaiter.IsCompleted)
 1091                    {
 1092                        TryInvokeContinuationT6(this, awaiter);
 1093                    }
 1094                    else
 1095                    {
 1096                        awaiter.SourceOnCompleted(state =>
 1097                        {
 1098                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T6>.Awaiter>)
 1099                            {
 1100                                TryInvokeContinuationT6(t.Item1, t.Item2);
 1101                            }
 1102                        }, StateTuple.Create(this, awaiter));
 1103                    }
 1104                }
 1105                {
 1106                    var awaiter = task7.GetAwaiter();
 1107
 1108                    if (awaiter.IsCompleted)
 1109                    {
 1110                        TryInvokeContinuationT7(this, awaiter);
 1111                    }
 1112                    else
 1113                    {
 1114                        awaiter.SourceOnCompleted(state =>
 1115                        {
 1116                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7>, UniTask<T7>.Awaiter>)
 1117                            {
 1118                                TryInvokeContinuationT7(t.Item1, t.Item2);
 1119                            }
 1120                        }, StateTuple.Create(this, awaiter));
 1121                    }
 1122                }
 1123            }
 1124
 1125            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T1>.Awaiter 
 1126            {
 1127                T1 result;
 1128                try
 1129                {
 1130                    result = awaiter.GetResult();
 1131                }
 1132                catch (Exception ex)
 1133                {
 1134                    self.core.TrySetException(ex);
 1135                    return;
 1136                }
 1137
 1138                if (Interlocked.Increment(ref self.completedCount) == 1)
 1139                {
 1140                    self.core.TrySetResult((0, result, default, default, default, default, default, default));
 1141                }
 1142            }
 1143
 1144            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T2>.Awaiter 
 1145            {
 1146                T2 result;
 1147                try
 1148                {
 1149                    result = awaiter.GetResult();
 1150                }
 1151                catch (Exception ex)
 1152                {
 1153                    self.core.TrySetException(ex);
 1154                    return;
 1155                }
 1156
 1157                if (Interlocked.Increment(ref self.completedCount) == 1)
 1158                {
 1159                    self.core.TrySetResult((1, default, result, default, default, default, default, default));
 1160                }
 1161            }
 1162
 1163            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T3>.Awaiter 
 1164            {
 1165                T3 result;
 1166                try
 1167                {
 1168                    result = awaiter.GetResult();
 1169                }
 1170                catch (Exception ex)
 1171                {
 1172                    self.core.TrySetException(ex);
 1173                    return;
 1174                }
 1175
 1176                if (Interlocked.Increment(ref self.completedCount) == 1)
 1177                {
 1178                    self.core.TrySetResult((2, default, default, result, default, default, default, default));
 1179                }
 1180            }
 1181
 1182            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T4>.Awaiter 
 1183            {
 1184                T4 result;
 1185                try
 1186                {
 1187                    result = awaiter.GetResult();
 1188                }
 1189                catch (Exception ex)
 1190                {
 1191                    self.core.TrySetException(ex);
 1192                    return;
 1193                }
 1194
 1195                if (Interlocked.Increment(ref self.completedCount) == 1)
 1196                {
 1197                    self.core.TrySetResult((3, default, default, default, result, default, default, default));
 1198                }
 1199            }
 1200
 1201            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T5>.Awaiter 
 1202            {
 1203                T5 result;
 1204                try
 1205                {
 1206                    result = awaiter.GetResult();
 1207                }
 1208                catch (Exception ex)
 1209                {
 1210                    self.core.TrySetException(ex);
 1211                    return;
 1212                }
 1213
 1214                if (Interlocked.Increment(ref self.completedCount) == 1)
 1215                {
 1216                    self.core.TrySetResult((4, default, default, default, default, result, default, default));
 1217                }
 1218            }
 1219
 1220            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T6>.Awaiter 
 1221            {
 1222                T6 result;
 1223                try
 1224                {
 1225                    result = awaiter.GetResult();
 1226                }
 1227                catch (Exception ex)
 1228                {
 1229                    self.core.TrySetException(ex);
 1230                    return;
 1231                }
 1232
 1233                if (Interlocked.Increment(ref self.completedCount) == 1)
 1234                {
 1235                    self.core.TrySetResult((5, default, default, default, default, default, result, default));
 1236                }
 1237            }
 1238
 1239            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7> self, in UniTask<T7>.Awaiter 
 1240            {
 1241                T7 result;
 1242                try
 1243                {
 1244                    result = awaiter.GetResult();
 1245                }
 1246                catch (Exception ex)
 1247                {
 1248                    self.core.TrySetException(ex);
 1249                    return;
 1250                }
 1251
 1252                if (Interlocked.Increment(ref self.completedCount) == 1)
 1253                {
 1254                    self.core.TrySetResult((6, default, default, default, default, default, default, result));
 1255                }
 1256            }
 1257
 1258
 1259            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7) GetResult(s
 1260            {
 1261                TaskTracker.RemoveTracking(this);
 1262                GC.SuppressFinalize(this);
 1263                return core.GetResult(token);
 1264            }
 1265
 1266            public UniTaskStatus GetStatus(short token)
 1267            {
 1268                return core.GetStatus(token);
 1269            }
 1270
 1271            public void OnCompleted(Action<object> continuation, object state, short token)
 1272            {
 1273                core.OnCompleted(continuation, state, token);
 1274            }
 1275
 1276            public UniTaskStatus UnsafeGetStatus()
 1277            {
 1278                return core.UnsafeGetStatus();
 1279            }
 1280
 1281            void IUniTaskSource.GetResult(short token)
 1282            {
 1283                GetResult(token);
 1284            }
 1285        }
 1286
 1287        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 01288        {
 01289            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 01290        }
 1291
 1292        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> : IUniTaskSource<(int, T1 result1, T2 result2, T3 re
 1293        {
 1294            int completedCount;
 1295            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 1296
 1297            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 1298            {
 1299                TaskTracker.TrackActiveTask(this, 3);
 1300
 1301                this.completedCount = 0;
 1302                {
 1303                    var awaiter = task1.GetAwaiter();
 1304
 1305                    if (awaiter.IsCompleted)
 1306                    {
 1307                        TryInvokeContinuationT1(this, awaiter);
 1308                    }
 1309                    else
 1310                    {
 1311                        awaiter.SourceOnCompleted(state =>
 1312                        {
 1313                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T1>.Await
 1314                            {
 1315                                TryInvokeContinuationT1(t.Item1, t.Item2);
 1316                            }
 1317                        }, StateTuple.Create(this, awaiter));
 1318                    }
 1319                }
 1320                {
 1321                    var awaiter = task2.GetAwaiter();
 1322
 1323                    if (awaiter.IsCompleted)
 1324                    {
 1325                        TryInvokeContinuationT2(this, awaiter);
 1326                    }
 1327                    else
 1328                    {
 1329                        awaiter.SourceOnCompleted(state =>
 1330                        {
 1331                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T2>.Await
 1332                            {
 1333                                TryInvokeContinuationT2(t.Item1, t.Item2);
 1334                            }
 1335                        }, StateTuple.Create(this, awaiter));
 1336                    }
 1337                }
 1338                {
 1339                    var awaiter = task3.GetAwaiter();
 1340
 1341                    if (awaiter.IsCompleted)
 1342                    {
 1343                        TryInvokeContinuationT3(this, awaiter);
 1344                    }
 1345                    else
 1346                    {
 1347                        awaiter.SourceOnCompleted(state =>
 1348                        {
 1349                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T3>.Await
 1350                            {
 1351                                TryInvokeContinuationT3(t.Item1, t.Item2);
 1352                            }
 1353                        }, StateTuple.Create(this, awaiter));
 1354                    }
 1355                }
 1356                {
 1357                    var awaiter = task4.GetAwaiter();
 1358
 1359                    if (awaiter.IsCompleted)
 1360                    {
 1361                        TryInvokeContinuationT4(this, awaiter);
 1362                    }
 1363                    else
 1364                    {
 1365                        awaiter.SourceOnCompleted(state =>
 1366                        {
 1367                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T4>.Await
 1368                            {
 1369                                TryInvokeContinuationT4(t.Item1, t.Item2);
 1370                            }
 1371                        }, StateTuple.Create(this, awaiter));
 1372                    }
 1373                }
 1374                {
 1375                    var awaiter = task5.GetAwaiter();
 1376
 1377                    if (awaiter.IsCompleted)
 1378                    {
 1379                        TryInvokeContinuationT5(this, awaiter);
 1380                    }
 1381                    else
 1382                    {
 1383                        awaiter.SourceOnCompleted(state =>
 1384                        {
 1385                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T5>.Await
 1386                            {
 1387                                TryInvokeContinuationT5(t.Item1, t.Item2);
 1388                            }
 1389                        }, StateTuple.Create(this, awaiter));
 1390                    }
 1391                }
 1392                {
 1393                    var awaiter = task6.GetAwaiter();
 1394
 1395                    if (awaiter.IsCompleted)
 1396                    {
 1397                        TryInvokeContinuationT6(this, awaiter);
 1398                    }
 1399                    else
 1400                    {
 1401                        awaiter.SourceOnCompleted(state =>
 1402                        {
 1403                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T6>.Await
 1404                            {
 1405                                TryInvokeContinuationT6(t.Item1, t.Item2);
 1406                            }
 1407                        }, StateTuple.Create(this, awaiter));
 1408                    }
 1409                }
 1410                {
 1411                    var awaiter = task7.GetAwaiter();
 1412
 1413                    if (awaiter.IsCompleted)
 1414                    {
 1415                        TryInvokeContinuationT7(this, awaiter);
 1416                    }
 1417                    else
 1418                    {
 1419                        awaiter.SourceOnCompleted(state =>
 1420                        {
 1421                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T7>.Await
 1422                            {
 1423                                TryInvokeContinuationT7(t.Item1, t.Item2);
 1424                            }
 1425                        }, StateTuple.Create(this, awaiter));
 1426                    }
 1427                }
 1428                {
 1429                    var awaiter = task8.GetAwaiter();
 1430
 1431                    if (awaiter.IsCompleted)
 1432                    {
 1433                        TryInvokeContinuationT8(this, awaiter);
 1434                    }
 1435                    else
 1436                    {
 1437                        awaiter.SourceOnCompleted(state =>
 1438                        {
 1439                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8>, UniTask<T8>.Await
 1440                            {
 1441                                TryInvokeContinuationT8(t.Item1, t.Item2);
 1442                            }
 1443                        }, StateTuple.Create(this, awaiter));
 1444                    }
 1445                }
 1446            }
 1447
 1448            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T1>.Awai
 1449            {
 1450                T1 result;
 1451                try
 1452                {
 1453                    result = awaiter.GetResult();
 1454                }
 1455                catch (Exception ex)
 1456                {
 1457                    self.core.TrySetException(ex);
 1458                    return;
 1459                }
 1460
 1461                if (Interlocked.Increment(ref self.completedCount) == 1)
 1462                {
 1463                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default));
 1464                }
 1465            }
 1466
 1467            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T2>.Awai
 1468            {
 1469                T2 result;
 1470                try
 1471                {
 1472                    result = awaiter.GetResult();
 1473                }
 1474                catch (Exception ex)
 1475                {
 1476                    self.core.TrySetException(ex);
 1477                    return;
 1478                }
 1479
 1480                if (Interlocked.Increment(ref self.completedCount) == 1)
 1481                {
 1482                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default));
 1483                }
 1484            }
 1485
 1486            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T3>.Awai
 1487            {
 1488                T3 result;
 1489                try
 1490                {
 1491                    result = awaiter.GetResult();
 1492                }
 1493                catch (Exception ex)
 1494                {
 1495                    self.core.TrySetException(ex);
 1496                    return;
 1497                }
 1498
 1499                if (Interlocked.Increment(ref self.completedCount) == 1)
 1500                {
 1501                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default));
 1502                }
 1503            }
 1504
 1505            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T4>.Awai
 1506            {
 1507                T4 result;
 1508                try
 1509                {
 1510                    result = awaiter.GetResult();
 1511                }
 1512                catch (Exception ex)
 1513                {
 1514                    self.core.TrySetException(ex);
 1515                    return;
 1516                }
 1517
 1518                if (Interlocked.Increment(ref self.completedCount) == 1)
 1519                {
 1520                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default));
 1521                }
 1522            }
 1523
 1524            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T5>.Awai
 1525            {
 1526                T5 result;
 1527                try
 1528                {
 1529                    result = awaiter.GetResult();
 1530                }
 1531                catch (Exception ex)
 1532                {
 1533                    self.core.TrySetException(ex);
 1534                    return;
 1535                }
 1536
 1537                if (Interlocked.Increment(ref self.completedCount) == 1)
 1538                {
 1539                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default));
 1540                }
 1541            }
 1542
 1543            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T6>.Awai
 1544            {
 1545                T6 result;
 1546                try
 1547                {
 1548                    result = awaiter.GetResult();
 1549                }
 1550                catch (Exception ex)
 1551                {
 1552                    self.core.TrySetException(ex);
 1553                    return;
 1554                }
 1555
 1556                if (Interlocked.Increment(ref self.completedCount) == 1)
 1557                {
 1558                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default));
 1559                }
 1560            }
 1561
 1562            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T7>.Awai
 1563            {
 1564                T7 result;
 1565                try
 1566                {
 1567                    result = awaiter.GetResult();
 1568                }
 1569                catch (Exception ex)
 1570                {
 1571                    self.core.TrySetException(ex);
 1572                    return;
 1573                }
 1574
 1575                if (Interlocked.Increment(ref self.completedCount) == 1)
 1576                {
 1577                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default));
 1578                }
 1579            }
 1580
 1581            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8> self, in UniTask<T8>.Awai
 1582            {
 1583                T8 result;
 1584                try
 1585                {
 1586                    result = awaiter.GetResult();
 1587                }
 1588                catch (Exception ex)
 1589                {
 1590                    self.core.TrySetException(ex);
 1591                    return;
 1592                }
 1593
 1594                if (Interlocked.Increment(ref self.completedCount) == 1)
 1595                {
 1596                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result));
 1597                }
 1598            }
 1599
 1600
 1601            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8)
 1602            {
 1603                TaskTracker.RemoveTracking(this);
 1604                GC.SuppressFinalize(this);
 1605                return core.GetResult(token);
 1606            }
 1607
 1608            public UniTaskStatus GetStatus(short token)
 1609            {
 1610                return core.GetStatus(token);
 1611            }
 1612
 1613            public void OnCompleted(Action<object> continuation, object state, short token)
 1614            {
 1615                core.OnCompleted(continuation, state, token);
 1616            }
 1617
 1618            public UniTaskStatus UnsafeGetStatus()
 1619            {
 1620                return core.UnsafeGetStatus();
 1621            }
 1622
 1623            void IUniTaskSource.GetResult(short token)
 1624            {
 1625                GetResult(token);
 1626            }
 1627        }
 1628
 1629        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 01630        {
 01631            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 01632        }
 1633
 1634        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> : IUniTaskSource<(int, T1 result1, T2 result2, T
 1635        {
 1636            int completedCount;
 1637            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 1638
 1639            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 1640            {
 1641                TaskTracker.TrackActiveTask(this, 3);
 1642
 1643                this.completedCount = 0;
 1644                {
 1645                    var awaiter = task1.GetAwaiter();
 1646
 1647                    if (awaiter.IsCompleted)
 1648                    {
 1649                        TryInvokeContinuationT1(this, awaiter);
 1650                    }
 1651                    else
 1652                    {
 1653                        awaiter.SourceOnCompleted(state =>
 1654                        {
 1655                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T1>.A
 1656                            {
 1657                                TryInvokeContinuationT1(t.Item1, t.Item2);
 1658                            }
 1659                        }, StateTuple.Create(this, awaiter));
 1660                    }
 1661                }
 1662                {
 1663                    var awaiter = task2.GetAwaiter();
 1664
 1665                    if (awaiter.IsCompleted)
 1666                    {
 1667                        TryInvokeContinuationT2(this, awaiter);
 1668                    }
 1669                    else
 1670                    {
 1671                        awaiter.SourceOnCompleted(state =>
 1672                        {
 1673                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T2>.A
 1674                            {
 1675                                TryInvokeContinuationT2(t.Item1, t.Item2);
 1676                            }
 1677                        }, StateTuple.Create(this, awaiter));
 1678                    }
 1679                }
 1680                {
 1681                    var awaiter = task3.GetAwaiter();
 1682
 1683                    if (awaiter.IsCompleted)
 1684                    {
 1685                        TryInvokeContinuationT3(this, awaiter);
 1686                    }
 1687                    else
 1688                    {
 1689                        awaiter.SourceOnCompleted(state =>
 1690                        {
 1691                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T3>.A
 1692                            {
 1693                                TryInvokeContinuationT3(t.Item1, t.Item2);
 1694                            }
 1695                        }, StateTuple.Create(this, awaiter));
 1696                    }
 1697                }
 1698                {
 1699                    var awaiter = task4.GetAwaiter();
 1700
 1701                    if (awaiter.IsCompleted)
 1702                    {
 1703                        TryInvokeContinuationT4(this, awaiter);
 1704                    }
 1705                    else
 1706                    {
 1707                        awaiter.SourceOnCompleted(state =>
 1708                        {
 1709                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T4>.A
 1710                            {
 1711                                TryInvokeContinuationT4(t.Item1, t.Item2);
 1712                            }
 1713                        }, StateTuple.Create(this, awaiter));
 1714                    }
 1715                }
 1716                {
 1717                    var awaiter = task5.GetAwaiter();
 1718
 1719                    if (awaiter.IsCompleted)
 1720                    {
 1721                        TryInvokeContinuationT5(this, awaiter);
 1722                    }
 1723                    else
 1724                    {
 1725                        awaiter.SourceOnCompleted(state =>
 1726                        {
 1727                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T5>.A
 1728                            {
 1729                                TryInvokeContinuationT5(t.Item1, t.Item2);
 1730                            }
 1731                        }, StateTuple.Create(this, awaiter));
 1732                    }
 1733                }
 1734                {
 1735                    var awaiter = task6.GetAwaiter();
 1736
 1737                    if (awaiter.IsCompleted)
 1738                    {
 1739                        TryInvokeContinuationT6(this, awaiter);
 1740                    }
 1741                    else
 1742                    {
 1743                        awaiter.SourceOnCompleted(state =>
 1744                        {
 1745                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T6>.A
 1746                            {
 1747                                TryInvokeContinuationT6(t.Item1, t.Item2);
 1748                            }
 1749                        }, StateTuple.Create(this, awaiter));
 1750                    }
 1751                }
 1752                {
 1753                    var awaiter = task7.GetAwaiter();
 1754
 1755                    if (awaiter.IsCompleted)
 1756                    {
 1757                        TryInvokeContinuationT7(this, awaiter);
 1758                    }
 1759                    else
 1760                    {
 1761                        awaiter.SourceOnCompleted(state =>
 1762                        {
 1763                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T7>.A
 1764                            {
 1765                                TryInvokeContinuationT7(t.Item1, t.Item2);
 1766                            }
 1767                        }, StateTuple.Create(this, awaiter));
 1768                    }
 1769                }
 1770                {
 1771                    var awaiter = task8.GetAwaiter();
 1772
 1773                    if (awaiter.IsCompleted)
 1774                    {
 1775                        TryInvokeContinuationT8(this, awaiter);
 1776                    }
 1777                    else
 1778                    {
 1779                        awaiter.SourceOnCompleted(state =>
 1780                        {
 1781                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T8>.A
 1782                            {
 1783                                TryInvokeContinuationT8(t.Item1, t.Item2);
 1784                            }
 1785                        }, StateTuple.Create(this, awaiter));
 1786                    }
 1787                }
 1788                {
 1789                    var awaiter = task9.GetAwaiter();
 1790
 1791                    if (awaiter.IsCompleted)
 1792                    {
 1793                        TryInvokeContinuationT9(this, awaiter);
 1794                    }
 1795                    else
 1796                    {
 1797                        awaiter.SourceOnCompleted(state =>
 1798                        {
 1799                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9>, UniTask<T9>.A
 1800                            {
 1801                                TryInvokeContinuationT9(t.Item1, t.Item2);
 1802                            }
 1803                        }, StateTuple.Create(this, awaiter));
 1804                    }
 1805                }
 1806            }
 1807
 1808            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T1>.
 1809            {
 1810                T1 result;
 1811                try
 1812                {
 1813                    result = awaiter.GetResult();
 1814                }
 1815                catch (Exception ex)
 1816                {
 1817                    self.core.TrySetException(ex);
 1818                    return;
 1819                }
 1820
 1821                if (Interlocked.Increment(ref self.completedCount) == 1)
 1822                {
 1823                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default, de
 1824                }
 1825            }
 1826
 1827            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T2>.
 1828            {
 1829                T2 result;
 1830                try
 1831                {
 1832                    result = awaiter.GetResult();
 1833                }
 1834                catch (Exception ex)
 1835                {
 1836                    self.core.TrySetException(ex);
 1837                    return;
 1838                }
 1839
 1840                if (Interlocked.Increment(ref self.completedCount) == 1)
 1841                {
 1842                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default, de
 1843                }
 1844            }
 1845
 1846            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T3>.
 1847            {
 1848                T3 result;
 1849                try
 1850                {
 1851                    result = awaiter.GetResult();
 1852                }
 1853                catch (Exception ex)
 1854                {
 1855                    self.core.TrySetException(ex);
 1856                    return;
 1857                }
 1858
 1859                if (Interlocked.Increment(ref self.completedCount) == 1)
 1860                {
 1861                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default, de
 1862                }
 1863            }
 1864
 1865            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T4>.
 1866            {
 1867                T4 result;
 1868                try
 1869                {
 1870                    result = awaiter.GetResult();
 1871                }
 1872                catch (Exception ex)
 1873                {
 1874                    self.core.TrySetException(ex);
 1875                    return;
 1876                }
 1877
 1878                if (Interlocked.Increment(ref self.completedCount) == 1)
 1879                {
 1880                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default, de
 1881                }
 1882            }
 1883
 1884            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T5>.
 1885            {
 1886                T5 result;
 1887                try
 1888                {
 1889                    result = awaiter.GetResult();
 1890                }
 1891                catch (Exception ex)
 1892                {
 1893                    self.core.TrySetException(ex);
 1894                    return;
 1895                }
 1896
 1897                if (Interlocked.Increment(ref self.completedCount) == 1)
 1898                {
 1899                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default, de
 1900                }
 1901            }
 1902
 1903            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T6>.
 1904            {
 1905                T6 result;
 1906                try
 1907                {
 1908                    result = awaiter.GetResult();
 1909                }
 1910                catch (Exception ex)
 1911                {
 1912                    self.core.TrySetException(ex);
 1913                    return;
 1914                }
 1915
 1916                if (Interlocked.Increment(ref self.completedCount) == 1)
 1917                {
 1918                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default, de
 1919                }
 1920            }
 1921
 1922            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T7>.
 1923            {
 1924                T7 result;
 1925                try
 1926                {
 1927                    result = awaiter.GetResult();
 1928                }
 1929                catch (Exception ex)
 1930                {
 1931                    self.core.TrySetException(ex);
 1932                    return;
 1933                }
 1934
 1935                if (Interlocked.Increment(ref self.completedCount) == 1)
 1936                {
 1937                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default, de
 1938                }
 1939            }
 1940
 1941            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T8>.
 1942            {
 1943                T8 result;
 1944                try
 1945                {
 1946                    result = awaiter.GetResult();
 1947                }
 1948                catch (Exception ex)
 1949                {
 1950                    self.core.TrySetException(ex);
 1951                    return;
 1952                }
 1953
 1954                if (Interlocked.Increment(ref self.completedCount) == 1)
 1955                {
 1956                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result, de
 1957                }
 1958            }
 1959
 1960            static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9> self, in UniTask<T9>.
 1961            {
 1962                T9 result;
 1963                try
 1964                {
 1965                    result = awaiter.GetResult();
 1966                }
 1967                catch (Exception ex)
 1968                {
 1969                    self.core.TrySetException(ex);
 1970                    return;
 1971                }
 1972
 1973                if (Interlocked.Increment(ref self.completedCount) == 1)
 1974                {
 1975                    self.core.TrySetResult((8, default, default, default, default, default, default, default, default, r
 1976                }
 1977            }
 1978
 1979
 1980            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8,
 1981            {
 1982                TaskTracker.RemoveTracking(this);
 1983                GC.SuppressFinalize(this);
 1984                return core.GetResult(token);
 1985            }
 1986
 1987            public UniTaskStatus GetStatus(short token)
 1988            {
 1989                return core.GetStatus(token);
 1990            }
 1991
 1992            public void OnCompleted(Action<object> continuation, object state, short token)
 1993            {
 1994                core.OnCompleted(continuation, state, token);
 1995            }
 1996
 1997            public UniTaskStatus UnsafeGetStatus()
 1998            {
 1999                return core.UnsafeGetStatus();
 2000            }
 2001
 2002            void IUniTaskSource.GetResult(short token)
 2003            {
 2004                GetResult(token);
 2005            }
 2006        }
 2007
 2008        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 02009        {
 02010            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 02011        }
 2012
 2013        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : IUniTaskSource<(int, T1 result1, T2 resul
 2014        {
 2015            int completedCount;
 2016            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 2017
 2018            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 2019            {
 2020                TaskTracker.TrackActiveTask(this, 3);
 2021
 2022                this.completedCount = 0;
 2023                {
 2024                    var awaiter = task1.GetAwaiter();
 2025
 2026                    if (awaiter.IsCompleted)
 2027                    {
 2028                        TryInvokeContinuationT1(this, awaiter);
 2029                    }
 2030                    else
 2031                    {
 2032                        awaiter.SourceOnCompleted(state =>
 2033                        {
 2034                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2035                            {
 2036                                TryInvokeContinuationT1(t.Item1, t.Item2);
 2037                            }
 2038                        }, StateTuple.Create(this, awaiter));
 2039                    }
 2040                }
 2041                {
 2042                    var awaiter = task2.GetAwaiter();
 2043
 2044                    if (awaiter.IsCompleted)
 2045                    {
 2046                        TryInvokeContinuationT2(this, awaiter);
 2047                    }
 2048                    else
 2049                    {
 2050                        awaiter.SourceOnCompleted(state =>
 2051                        {
 2052                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2053                            {
 2054                                TryInvokeContinuationT2(t.Item1, t.Item2);
 2055                            }
 2056                        }, StateTuple.Create(this, awaiter));
 2057                    }
 2058                }
 2059                {
 2060                    var awaiter = task3.GetAwaiter();
 2061
 2062                    if (awaiter.IsCompleted)
 2063                    {
 2064                        TryInvokeContinuationT3(this, awaiter);
 2065                    }
 2066                    else
 2067                    {
 2068                        awaiter.SourceOnCompleted(state =>
 2069                        {
 2070                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2071                            {
 2072                                TryInvokeContinuationT3(t.Item1, t.Item2);
 2073                            }
 2074                        }, StateTuple.Create(this, awaiter));
 2075                    }
 2076                }
 2077                {
 2078                    var awaiter = task4.GetAwaiter();
 2079
 2080                    if (awaiter.IsCompleted)
 2081                    {
 2082                        TryInvokeContinuationT4(this, awaiter);
 2083                    }
 2084                    else
 2085                    {
 2086                        awaiter.SourceOnCompleted(state =>
 2087                        {
 2088                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2089                            {
 2090                                TryInvokeContinuationT4(t.Item1, t.Item2);
 2091                            }
 2092                        }, StateTuple.Create(this, awaiter));
 2093                    }
 2094                }
 2095                {
 2096                    var awaiter = task5.GetAwaiter();
 2097
 2098                    if (awaiter.IsCompleted)
 2099                    {
 2100                        TryInvokeContinuationT5(this, awaiter);
 2101                    }
 2102                    else
 2103                    {
 2104                        awaiter.SourceOnCompleted(state =>
 2105                        {
 2106                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2107                            {
 2108                                TryInvokeContinuationT5(t.Item1, t.Item2);
 2109                            }
 2110                        }, StateTuple.Create(this, awaiter));
 2111                    }
 2112                }
 2113                {
 2114                    var awaiter = task6.GetAwaiter();
 2115
 2116                    if (awaiter.IsCompleted)
 2117                    {
 2118                        TryInvokeContinuationT6(this, awaiter);
 2119                    }
 2120                    else
 2121                    {
 2122                        awaiter.SourceOnCompleted(state =>
 2123                        {
 2124                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2125                            {
 2126                                TryInvokeContinuationT6(t.Item1, t.Item2);
 2127                            }
 2128                        }, StateTuple.Create(this, awaiter));
 2129                    }
 2130                }
 2131                {
 2132                    var awaiter = task7.GetAwaiter();
 2133
 2134                    if (awaiter.IsCompleted)
 2135                    {
 2136                        TryInvokeContinuationT7(this, awaiter);
 2137                    }
 2138                    else
 2139                    {
 2140                        awaiter.SourceOnCompleted(state =>
 2141                        {
 2142                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2143                            {
 2144                                TryInvokeContinuationT7(t.Item1, t.Item2);
 2145                            }
 2146                        }, StateTuple.Create(this, awaiter));
 2147                    }
 2148                }
 2149                {
 2150                    var awaiter = task8.GetAwaiter();
 2151
 2152                    if (awaiter.IsCompleted)
 2153                    {
 2154                        TryInvokeContinuationT8(this, awaiter);
 2155                    }
 2156                    else
 2157                    {
 2158                        awaiter.SourceOnCompleted(state =>
 2159                        {
 2160                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2161                            {
 2162                                TryInvokeContinuationT8(t.Item1, t.Item2);
 2163                            }
 2164                        }, StateTuple.Create(this, awaiter));
 2165                    }
 2166                }
 2167                {
 2168                    var awaiter = task9.GetAwaiter();
 2169
 2170                    if (awaiter.IsCompleted)
 2171                    {
 2172                        TryInvokeContinuationT9(this, awaiter);
 2173                    }
 2174                    else
 2175                    {
 2176                        awaiter.SourceOnCompleted(state =>
 2177                        {
 2178                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2179                            {
 2180                                TryInvokeContinuationT9(t.Item1, t.Item2);
 2181                            }
 2182                        }, StateTuple.Create(this, awaiter));
 2183                    }
 2184                }
 2185                {
 2186                    var awaiter = task10.GetAwaiter();
 2187
 2188                    if (awaiter.IsCompleted)
 2189                    {
 2190                        TryInvokeContinuationT10(this, awaiter);
 2191                    }
 2192                    else
 2193                    {
 2194                        awaiter.SourceOnCompleted(state =>
 2195                        {
 2196                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, UniTask<
 2197                            {
 2198                                TryInvokeContinuationT10(t.Item1, t.Item2);
 2199                            }
 2200                        }, StateTuple.Create(this, awaiter));
 2201                    }
 2202                }
 2203            }
 2204
 2205            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2206            {
 2207                T1 result;
 2208                try
 2209                {
 2210                    result = awaiter.GetResult();
 2211                }
 2212                catch (Exception ex)
 2213                {
 2214                    self.core.TrySetException(ex);
 2215                    return;
 2216                }
 2217
 2218                if (Interlocked.Increment(ref self.completedCount) == 1)
 2219                {
 2220                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default, de
 2221                }
 2222            }
 2223
 2224            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2225            {
 2226                T2 result;
 2227                try
 2228                {
 2229                    result = awaiter.GetResult();
 2230                }
 2231                catch (Exception ex)
 2232                {
 2233                    self.core.TrySetException(ex);
 2234                    return;
 2235                }
 2236
 2237                if (Interlocked.Increment(ref self.completedCount) == 1)
 2238                {
 2239                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default, de
 2240                }
 2241            }
 2242
 2243            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2244            {
 2245                T3 result;
 2246                try
 2247                {
 2248                    result = awaiter.GetResult();
 2249                }
 2250                catch (Exception ex)
 2251                {
 2252                    self.core.TrySetException(ex);
 2253                    return;
 2254                }
 2255
 2256                if (Interlocked.Increment(ref self.completedCount) == 1)
 2257                {
 2258                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default, de
 2259                }
 2260            }
 2261
 2262            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2263            {
 2264                T4 result;
 2265                try
 2266                {
 2267                    result = awaiter.GetResult();
 2268                }
 2269                catch (Exception ex)
 2270                {
 2271                    self.core.TrySetException(ex);
 2272                    return;
 2273                }
 2274
 2275                if (Interlocked.Increment(ref self.completedCount) == 1)
 2276                {
 2277                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default, de
 2278                }
 2279            }
 2280
 2281            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2282            {
 2283                T5 result;
 2284                try
 2285                {
 2286                    result = awaiter.GetResult();
 2287                }
 2288                catch (Exception ex)
 2289                {
 2290                    self.core.TrySetException(ex);
 2291                    return;
 2292                }
 2293
 2294                if (Interlocked.Increment(ref self.completedCount) == 1)
 2295                {
 2296                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default, de
 2297                }
 2298            }
 2299
 2300            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2301            {
 2302                T6 result;
 2303                try
 2304                {
 2305                    result = awaiter.GetResult();
 2306                }
 2307                catch (Exception ex)
 2308                {
 2309                    self.core.TrySetException(ex);
 2310                    return;
 2311                }
 2312
 2313                if (Interlocked.Increment(ref self.completedCount) == 1)
 2314                {
 2315                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default, de
 2316                }
 2317            }
 2318
 2319            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2320            {
 2321                T7 result;
 2322                try
 2323                {
 2324                    result = awaiter.GetResult();
 2325                }
 2326                catch (Exception ex)
 2327                {
 2328                    self.core.TrySetException(ex);
 2329                    return;
 2330                }
 2331
 2332                if (Interlocked.Increment(ref self.completedCount) == 1)
 2333                {
 2334                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default, de
 2335                }
 2336            }
 2337
 2338            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2339            {
 2340                T8 result;
 2341                try
 2342                {
 2343                    result = awaiter.GetResult();
 2344                }
 2345                catch (Exception ex)
 2346                {
 2347                    self.core.TrySetException(ex);
 2348                    return;
 2349                }
 2350
 2351                if (Interlocked.Increment(ref self.completedCount) == 1)
 2352                {
 2353                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result, de
 2354                }
 2355            }
 2356
 2357            static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTask
 2358            {
 2359                T9 result;
 2360                try
 2361                {
 2362                    result = awaiter.GetResult();
 2363                }
 2364                catch (Exception ex)
 2365                {
 2366                    self.core.TrySetException(ex);
 2367                    return;
 2368                }
 2369
 2370                if (Interlocked.Increment(ref self.completedCount) == 1)
 2371                {
 2372                    self.core.TrySetResult((8, default, default, default, default, default, default, default, default, r
 2373                }
 2374            }
 2375
 2376            static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> self, in UniTas
 2377            {
 2378                T10 result;
 2379                try
 2380                {
 2381                    result = awaiter.GetResult();
 2382                }
 2383                catch (Exception ex)
 2384                {
 2385                    self.core.TrySetException(ex);
 2386                    return;
 2387                }
 2388
 2389                if (Interlocked.Increment(ref self.completedCount) == 1)
 2390                {
 2391                    self.core.TrySetResult((9, default, default, default, default, default, default, default, default, d
 2392                }
 2393            }
 2394
 2395
 2396            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8,
 2397            {
 2398                TaskTracker.RemoveTracking(this);
 2399                GC.SuppressFinalize(this);
 2400                return core.GetResult(token);
 2401            }
 2402
 2403            public UniTaskStatus GetStatus(short token)
 2404            {
 2405                return core.GetStatus(token);
 2406            }
 2407
 2408            public void OnCompleted(Action<object> continuation, object state, short token)
 2409            {
 2410                core.OnCompleted(continuation, state, token);
 2411            }
 2412
 2413            public UniTaskStatus UnsafeGetStatus()
 2414            {
 2415                return core.UnsafeGetStatus();
 2416            }
 2417
 2418            void IUniTaskSource.GetResult(short token)
 2419            {
 2420                GetResult(token);
 2421            }
 2422        }
 2423
 2424        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 02425        {
 02426            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 02427        }
 2428
 2429        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : IUniTaskSource<(int, T1 result1, T2 
 2430        {
 2431            int completedCount;
 2432            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 2433
 2434            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 2435            {
 2436                TaskTracker.TrackActiveTask(this, 3);
 2437
 2438                this.completedCount = 0;
 2439                {
 2440                    var awaiter = task1.GetAwaiter();
 2441
 2442                    if (awaiter.IsCompleted)
 2443                    {
 2444                        TryInvokeContinuationT1(this, awaiter);
 2445                    }
 2446                    else
 2447                    {
 2448                        awaiter.SourceOnCompleted(state =>
 2449                        {
 2450                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2451                            {
 2452                                TryInvokeContinuationT1(t.Item1, t.Item2);
 2453                            }
 2454                        }, StateTuple.Create(this, awaiter));
 2455                    }
 2456                }
 2457                {
 2458                    var awaiter = task2.GetAwaiter();
 2459
 2460                    if (awaiter.IsCompleted)
 2461                    {
 2462                        TryInvokeContinuationT2(this, awaiter);
 2463                    }
 2464                    else
 2465                    {
 2466                        awaiter.SourceOnCompleted(state =>
 2467                        {
 2468                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2469                            {
 2470                                TryInvokeContinuationT2(t.Item1, t.Item2);
 2471                            }
 2472                        }, StateTuple.Create(this, awaiter));
 2473                    }
 2474                }
 2475                {
 2476                    var awaiter = task3.GetAwaiter();
 2477
 2478                    if (awaiter.IsCompleted)
 2479                    {
 2480                        TryInvokeContinuationT3(this, awaiter);
 2481                    }
 2482                    else
 2483                    {
 2484                        awaiter.SourceOnCompleted(state =>
 2485                        {
 2486                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2487                            {
 2488                                TryInvokeContinuationT3(t.Item1, t.Item2);
 2489                            }
 2490                        }, StateTuple.Create(this, awaiter));
 2491                    }
 2492                }
 2493                {
 2494                    var awaiter = task4.GetAwaiter();
 2495
 2496                    if (awaiter.IsCompleted)
 2497                    {
 2498                        TryInvokeContinuationT4(this, awaiter);
 2499                    }
 2500                    else
 2501                    {
 2502                        awaiter.SourceOnCompleted(state =>
 2503                        {
 2504                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2505                            {
 2506                                TryInvokeContinuationT4(t.Item1, t.Item2);
 2507                            }
 2508                        }, StateTuple.Create(this, awaiter));
 2509                    }
 2510                }
 2511                {
 2512                    var awaiter = task5.GetAwaiter();
 2513
 2514                    if (awaiter.IsCompleted)
 2515                    {
 2516                        TryInvokeContinuationT5(this, awaiter);
 2517                    }
 2518                    else
 2519                    {
 2520                        awaiter.SourceOnCompleted(state =>
 2521                        {
 2522                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2523                            {
 2524                                TryInvokeContinuationT5(t.Item1, t.Item2);
 2525                            }
 2526                        }, StateTuple.Create(this, awaiter));
 2527                    }
 2528                }
 2529                {
 2530                    var awaiter = task6.GetAwaiter();
 2531
 2532                    if (awaiter.IsCompleted)
 2533                    {
 2534                        TryInvokeContinuationT6(this, awaiter);
 2535                    }
 2536                    else
 2537                    {
 2538                        awaiter.SourceOnCompleted(state =>
 2539                        {
 2540                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2541                            {
 2542                                TryInvokeContinuationT6(t.Item1, t.Item2);
 2543                            }
 2544                        }, StateTuple.Create(this, awaiter));
 2545                    }
 2546                }
 2547                {
 2548                    var awaiter = task7.GetAwaiter();
 2549
 2550                    if (awaiter.IsCompleted)
 2551                    {
 2552                        TryInvokeContinuationT7(this, awaiter);
 2553                    }
 2554                    else
 2555                    {
 2556                        awaiter.SourceOnCompleted(state =>
 2557                        {
 2558                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2559                            {
 2560                                TryInvokeContinuationT7(t.Item1, t.Item2);
 2561                            }
 2562                        }, StateTuple.Create(this, awaiter));
 2563                    }
 2564                }
 2565                {
 2566                    var awaiter = task8.GetAwaiter();
 2567
 2568                    if (awaiter.IsCompleted)
 2569                    {
 2570                        TryInvokeContinuationT8(this, awaiter);
 2571                    }
 2572                    else
 2573                    {
 2574                        awaiter.SourceOnCompleted(state =>
 2575                        {
 2576                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2577                            {
 2578                                TryInvokeContinuationT8(t.Item1, t.Item2);
 2579                            }
 2580                        }, StateTuple.Create(this, awaiter));
 2581                    }
 2582                }
 2583                {
 2584                    var awaiter = task9.GetAwaiter();
 2585
 2586                    if (awaiter.IsCompleted)
 2587                    {
 2588                        TryInvokeContinuationT9(this, awaiter);
 2589                    }
 2590                    else
 2591                    {
 2592                        awaiter.SourceOnCompleted(state =>
 2593                        {
 2594                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2595                            {
 2596                                TryInvokeContinuationT9(t.Item1, t.Item2);
 2597                            }
 2598                        }, StateTuple.Create(this, awaiter));
 2599                    }
 2600                }
 2601                {
 2602                    var awaiter = task10.GetAwaiter();
 2603
 2604                    if (awaiter.IsCompleted)
 2605                    {
 2606                        TryInvokeContinuationT10(this, awaiter);
 2607                    }
 2608                    else
 2609                    {
 2610                        awaiter.SourceOnCompleted(state =>
 2611                        {
 2612                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2613                            {
 2614                                TryInvokeContinuationT10(t.Item1, t.Item2);
 2615                            }
 2616                        }, StateTuple.Create(this, awaiter));
 2617                    }
 2618                }
 2619                {
 2620                    var awaiter = task11.GetAwaiter();
 2621
 2622                    if (awaiter.IsCompleted)
 2623                    {
 2624                        TryInvokeContinuationT11(this, awaiter);
 2625                    }
 2626                    else
 2627                    {
 2628                        awaiter.SourceOnCompleted(state =>
 2629                        {
 2630                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Uni
 2631                            {
 2632                                TryInvokeContinuationT11(t.Item1, t.Item2);
 2633                            }
 2634                        }, StateTuple.Create(this, awaiter));
 2635                    }
 2636                }
 2637            }
 2638
 2639            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2640            {
 2641                T1 result;
 2642                try
 2643                {
 2644                    result = awaiter.GetResult();
 2645                }
 2646                catch (Exception ex)
 2647                {
 2648                    self.core.TrySetException(ex);
 2649                    return;
 2650                }
 2651
 2652                if (Interlocked.Increment(ref self.completedCount) == 1)
 2653                {
 2654                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default, de
 2655                }
 2656            }
 2657
 2658            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2659            {
 2660                T2 result;
 2661                try
 2662                {
 2663                    result = awaiter.GetResult();
 2664                }
 2665                catch (Exception ex)
 2666                {
 2667                    self.core.TrySetException(ex);
 2668                    return;
 2669                }
 2670
 2671                if (Interlocked.Increment(ref self.completedCount) == 1)
 2672                {
 2673                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default, de
 2674                }
 2675            }
 2676
 2677            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2678            {
 2679                T3 result;
 2680                try
 2681                {
 2682                    result = awaiter.GetResult();
 2683                }
 2684                catch (Exception ex)
 2685                {
 2686                    self.core.TrySetException(ex);
 2687                    return;
 2688                }
 2689
 2690                if (Interlocked.Increment(ref self.completedCount) == 1)
 2691                {
 2692                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default, de
 2693                }
 2694            }
 2695
 2696            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2697            {
 2698                T4 result;
 2699                try
 2700                {
 2701                    result = awaiter.GetResult();
 2702                }
 2703                catch (Exception ex)
 2704                {
 2705                    self.core.TrySetException(ex);
 2706                    return;
 2707                }
 2708
 2709                if (Interlocked.Increment(ref self.completedCount) == 1)
 2710                {
 2711                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default, de
 2712                }
 2713            }
 2714
 2715            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2716            {
 2717                T5 result;
 2718                try
 2719                {
 2720                    result = awaiter.GetResult();
 2721                }
 2722                catch (Exception ex)
 2723                {
 2724                    self.core.TrySetException(ex);
 2725                    return;
 2726                }
 2727
 2728                if (Interlocked.Increment(ref self.completedCount) == 1)
 2729                {
 2730                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default, de
 2731                }
 2732            }
 2733
 2734            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2735            {
 2736                T6 result;
 2737                try
 2738                {
 2739                    result = awaiter.GetResult();
 2740                }
 2741                catch (Exception ex)
 2742                {
 2743                    self.core.TrySetException(ex);
 2744                    return;
 2745                }
 2746
 2747                if (Interlocked.Increment(ref self.completedCount) == 1)
 2748                {
 2749                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default, de
 2750                }
 2751            }
 2752
 2753            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2754            {
 2755                T7 result;
 2756                try
 2757                {
 2758                    result = awaiter.GetResult();
 2759                }
 2760                catch (Exception ex)
 2761                {
 2762                    self.core.TrySetException(ex);
 2763                    return;
 2764                }
 2765
 2766                if (Interlocked.Increment(ref self.completedCount) == 1)
 2767                {
 2768                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default, de
 2769                }
 2770            }
 2771
 2772            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2773            {
 2774                T8 result;
 2775                try
 2776                {
 2777                    result = awaiter.GetResult();
 2778                }
 2779                catch (Exception ex)
 2780                {
 2781                    self.core.TrySetException(ex);
 2782                    return;
 2783                }
 2784
 2785                if (Interlocked.Increment(ref self.completedCount) == 1)
 2786                {
 2787                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result, de
 2788                }
 2789            }
 2790
 2791            static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in Un
 2792            {
 2793                T9 result;
 2794                try
 2795                {
 2796                    result = awaiter.GetResult();
 2797                }
 2798                catch (Exception ex)
 2799                {
 2800                    self.core.TrySetException(ex);
 2801                    return;
 2802                }
 2803
 2804                if (Interlocked.Increment(ref self.completedCount) == 1)
 2805                {
 2806                    self.core.TrySetResult((8, default, default, default, default, default, default, default, default, r
 2807                }
 2808            }
 2809
 2810            static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in U
 2811            {
 2812                T10 result;
 2813                try
 2814                {
 2815                    result = awaiter.GetResult();
 2816                }
 2817                catch (Exception ex)
 2818                {
 2819                    self.core.TrySetException(ex);
 2820                    return;
 2821                }
 2822
 2823                if (Interlocked.Increment(ref self.completedCount) == 1)
 2824                {
 2825                    self.core.TrySetResult((9, default, default, default, default, default, default, default, default, d
 2826                }
 2827            }
 2828
 2829            static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> self, in U
 2830            {
 2831                T11 result;
 2832                try
 2833                {
 2834                    result = awaiter.GetResult();
 2835                }
 2836                catch (Exception ex)
 2837                {
 2838                    self.core.TrySetException(ex);
 2839                    return;
 2840                }
 2841
 2842                if (Interlocked.Increment(ref self.completedCount) == 1)
 2843                {
 2844                    self.core.TrySetResult((10, default, default, default, default, default, default, default, default, 
 2845                }
 2846            }
 2847
 2848
 2849            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8,
 2850            {
 2851                TaskTracker.RemoveTracking(this);
 2852                GC.SuppressFinalize(this);
 2853                return core.GetResult(token);
 2854            }
 2855
 2856            public UniTaskStatus GetStatus(short token)
 2857            {
 2858                return core.GetStatus(token);
 2859            }
 2860
 2861            public void OnCompleted(Action<object> continuation, object state, short token)
 2862            {
 2863                core.OnCompleted(continuation, state, token);
 2864            }
 2865
 2866            public UniTaskStatus UnsafeGetStatus()
 2867            {
 2868                return core.UnsafeGetStatus();
 2869            }
 2870
 2871            void IUniTaskSource.GetResult(short token)
 2872            {
 2873                GetResult(token);
 2874            }
 2875        }
 2876
 2877        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 02878        {
 02879            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 02880        }
 2881
 2882        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : IUniTaskSource<(int, T1 result1
 2883        {
 2884            int completedCount;
 2885            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 2886
 2887            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 2888            {
 2889                TaskTracker.TrackActiveTask(this, 3);
 2890
 2891                this.completedCount = 0;
 2892                {
 2893                    var awaiter = task1.GetAwaiter();
 2894
 2895                    if (awaiter.IsCompleted)
 2896                    {
 2897                        TryInvokeContinuationT1(this, awaiter);
 2898                    }
 2899                    else
 2900                    {
 2901                        awaiter.SourceOnCompleted(state =>
 2902                        {
 2903                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2904                            {
 2905                                TryInvokeContinuationT1(t.Item1, t.Item2);
 2906                            }
 2907                        }, StateTuple.Create(this, awaiter));
 2908                    }
 2909                }
 2910                {
 2911                    var awaiter = task2.GetAwaiter();
 2912
 2913                    if (awaiter.IsCompleted)
 2914                    {
 2915                        TryInvokeContinuationT2(this, awaiter);
 2916                    }
 2917                    else
 2918                    {
 2919                        awaiter.SourceOnCompleted(state =>
 2920                        {
 2921                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2922                            {
 2923                                TryInvokeContinuationT2(t.Item1, t.Item2);
 2924                            }
 2925                        }, StateTuple.Create(this, awaiter));
 2926                    }
 2927                }
 2928                {
 2929                    var awaiter = task3.GetAwaiter();
 2930
 2931                    if (awaiter.IsCompleted)
 2932                    {
 2933                        TryInvokeContinuationT3(this, awaiter);
 2934                    }
 2935                    else
 2936                    {
 2937                        awaiter.SourceOnCompleted(state =>
 2938                        {
 2939                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2940                            {
 2941                                TryInvokeContinuationT3(t.Item1, t.Item2);
 2942                            }
 2943                        }, StateTuple.Create(this, awaiter));
 2944                    }
 2945                }
 2946                {
 2947                    var awaiter = task4.GetAwaiter();
 2948
 2949                    if (awaiter.IsCompleted)
 2950                    {
 2951                        TryInvokeContinuationT4(this, awaiter);
 2952                    }
 2953                    else
 2954                    {
 2955                        awaiter.SourceOnCompleted(state =>
 2956                        {
 2957                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2958                            {
 2959                                TryInvokeContinuationT4(t.Item1, t.Item2);
 2960                            }
 2961                        }, StateTuple.Create(this, awaiter));
 2962                    }
 2963                }
 2964                {
 2965                    var awaiter = task5.GetAwaiter();
 2966
 2967                    if (awaiter.IsCompleted)
 2968                    {
 2969                        TryInvokeContinuationT5(this, awaiter);
 2970                    }
 2971                    else
 2972                    {
 2973                        awaiter.SourceOnCompleted(state =>
 2974                        {
 2975                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2976                            {
 2977                                TryInvokeContinuationT5(t.Item1, t.Item2);
 2978                            }
 2979                        }, StateTuple.Create(this, awaiter));
 2980                    }
 2981                }
 2982                {
 2983                    var awaiter = task6.GetAwaiter();
 2984
 2985                    if (awaiter.IsCompleted)
 2986                    {
 2987                        TryInvokeContinuationT6(this, awaiter);
 2988                    }
 2989                    else
 2990                    {
 2991                        awaiter.SourceOnCompleted(state =>
 2992                        {
 2993                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 2994                            {
 2995                                TryInvokeContinuationT6(t.Item1, t.Item2);
 2996                            }
 2997                        }, StateTuple.Create(this, awaiter));
 2998                    }
 2999                }
 3000                {
 3001                    var awaiter = task7.GetAwaiter();
 3002
 3003                    if (awaiter.IsCompleted)
 3004                    {
 3005                        TryInvokeContinuationT7(this, awaiter);
 3006                    }
 3007                    else
 3008                    {
 3009                        awaiter.SourceOnCompleted(state =>
 3010                        {
 3011                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3012                            {
 3013                                TryInvokeContinuationT7(t.Item1, t.Item2);
 3014                            }
 3015                        }, StateTuple.Create(this, awaiter));
 3016                    }
 3017                }
 3018                {
 3019                    var awaiter = task8.GetAwaiter();
 3020
 3021                    if (awaiter.IsCompleted)
 3022                    {
 3023                        TryInvokeContinuationT8(this, awaiter);
 3024                    }
 3025                    else
 3026                    {
 3027                        awaiter.SourceOnCompleted(state =>
 3028                        {
 3029                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3030                            {
 3031                                TryInvokeContinuationT8(t.Item1, t.Item2);
 3032                            }
 3033                        }, StateTuple.Create(this, awaiter));
 3034                    }
 3035                }
 3036                {
 3037                    var awaiter = task9.GetAwaiter();
 3038
 3039                    if (awaiter.IsCompleted)
 3040                    {
 3041                        TryInvokeContinuationT9(this, awaiter);
 3042                    }
 3043                    else
 3044                    {
 3045                        awaiter.SourceOnCompleted(state =>
 3046                        {
 3047                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3048                            {
 3049                                TryInvokeContinuationT9(t.Item1, t.Item2);
 3050                            }
 3051                        }, StateTuple.Create(this, awaiter));
 3052                    }
 3053                }
 3054                {
 3055                    var awaiter = task10.GetAwaiter();
 3056
 3057                    if (awaiter.IsCompleted)
 3058                    {
 3059                        TryInvokeContinuationT10(this, awaiter);
 3060                    }
 3061                    else
 3062                    {
 3063                        awaiter.SourceOnCompleted(state =>
 3064                        {
 3065                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3066                            {
 3067                                TryInvokeContinuationT10(t.Item1, t.Item2);
 3068                            }
 3069                        }, StateTuple.Create(this, awaiter));
 3070                    }
 3071                }
 3072                {
 3073                    var awaiter = task11.GetAwaiter();
 3074
 3075                    if (awaiter.IsCompleted)
 3076                    {
 3077                        TryInvokeContinuationT11(this, awaiter);
 3078                    }
 3079                    else
 3080                    {
 3081                        awaiter.SourceOnCompleted(state =>
 3082                        {
 3083                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3084                            {
 3085                                TryInvokeContinuationT11(t.Item1, t.Item2);
 3086                            }
 3087                        }, StateTuple.Create(this, awaiter));
 3088                    }
 3089                }
 3090                {
 3091                    var awaiter = task12.GetAwaiter();
 3092
 3093                    if (awaiter.IsCompleted)
 3094                    {
 3095                        TryInvokeContinuationT12(this, awaiter);
 3096                    }
 3097                    else
 3098                    {
 3099                        awaiter.SourceOnCompleted(state =>
 3100                        {
 3101                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
 3102                            {
 3103                                TryInvokeContinuationT12(t.Item1, t.Item2);
 3104                            }
 3105                        }, StateTuple.Create(this, awaiter));
 3106                    }
 3107                }
 3108            }
 3109
 3110            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3111            {
 3112                T1 result;
 3113                try
 3114                {
 3115                    result = awaiter.GetResult();
 3116                }
 3117                catch (Exception ex)
 3118                {
 3119                    self.core.TrySetException(ex);
 3120                    return;
 3121                }
 3122
 3123                if (Interlocked.Increment(ref self.completedCount) == 1)
 3124                {
 3125                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default, de
 3126                }
 3127            }
 3128
 3129            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3130            {
 3131                T2 result;
 3132                try
 3133                {
 3134                    result = awaiter.GetResult();
 3135                }
 3136                catch (Exception ex)
 3137                {
 3138                    self.core.TrySetException(ex);
 3139                    return;
 3140                }
 3141
 3142                if (Interlocked.Increment(ref self.completedCount) == 1)
 3143                {
 3144                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default, de
 3145                }
 3146            }
 3147
 3148            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3149            {
 3150                T3 result;
 3151                try
 3152                {
 3153                    result = awaiter.GetResult();
 3154                }
 3155                catch (Exception ex)
 3156                {
 3157                    self.core.TrySetException(ex);
 3158                    return;
 3159                }
 3160
 3161                if (Interlocked.Increment(ref self.completedCount) == 1)
 3162                {
 3163                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default, de
 3164                }
 3165            }
 3166
 3167            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3168            {
 3169                T4 result;
 3170                try
 3171                {
 3172                    result = awaiter.GetResult();
 3173                }
 3174                catch (Exception ex)
 3175                {
 3176                    self.core.TrySetException(ex);
 3177                    return;
 3178                }
 3179
 3180                if (Interlocked.Increment(ref self.completedCount) == 1)
 3181                {
 3182                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default, de
 3183                }
 3184            }
 3185
 3186            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3187            {
 3188                T5 result;
 3189                try
 3190                {
 3191                    result = awaiter.GetResult();
 3192                }
 3193                catch (Exception ex)
 3194                {
 3195                    self.core.TrySetException(ex);
 3196                    return;
 3197                }
 3198
 3199                if (Interlocked.Increment(ref self.completedCount) == 1)
 3200                {
 3201                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default, de
 3202                }
 3203            }
 3204
 3205            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3206            {
 3207                T6 result;
 3208                try
 3209                {
 3210                    result = awaiter.GetResult();
 3211                }
 3212                catch (Exception ex)
 3213                {
 3214                    self.core.TrySetException(ex);
 3215                    return;
 3216                }
 3217
 3218                if (Interlocked.Increment(ref self.completedCount) == 1)
 3219                {
 3220                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default, de
 3221                }
 3222            }
 3223
 3224            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3225            {
 3226                T7 result;
 3227                try
 3228                {
 3229                    result = awaiter.GetResult();
 3230                }
 3231                catch (Exception ex)
 3232                {
 3233                    self.core.TrySetException(ex);
 3234                    return;
 3235                }
 3236
 3237                if (Interlocked.Increment(ref self.completedCount) == 1)
 3238                {
 3239                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default, de
 3240                }
 3241            }
 3242
 3243            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3244            {
 3245                T8 result;
 3246                try
 3247                {
 3248                    result = awaiter.GetResult();
 3249                }
 3250                catch (Exception ex)
 3251                {
 3252                    self.core.TrySetException(ex);
 3253                    return;
 3254                }
 3255
 3256                if (Interlocked.Increment(ref self.completedCount) == 1)
 3257                {
 3258                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result, de
 3259                }
 3260            }
 3261
 3262            static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self, 
 3263            {
 3264                T9 result;
 3265                try
 3266                {
 3267                    result = awaiter.GetResult();
 3268                }
 3269                catch (Exception ex)
 3270                {
 3271                    self.core.TrySetException(ex);
 3272                    return;
 3273                }
 3274
 3275                if (Interlocked.Increment(ref self.completedCount) == 1)
 3276                {
 3277                    self.core.TrySetResult((8, default, default, default, default, default, default, default, default, r
 3278                }
 3279            }
 3280
 3281            static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self,
 3282            {
 3283                T10 result;
 3284                try
 3285                {
 3286                    result = awaiter.GetResult();
 3287                }
 3288                catch (Exception ex)
 3289                {
 3290                    self.core.TrySetException(ex);
 3291                    return;
 3292                }
 3293
 3294                if (Interlocked.Increment(ref self.completedCount) == 1)
 3295                {
 3296                    self.core.TrySetResult((9, default, default, default, default, default, default, default, default, d
 3297                }
 3298            }
 3299
 3300            static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self,
 3301            {
 3302                T11 result;
 3303                try
 3304                {
 3305                    result = awaiter.GetResult();
 3306                }
 3307                catch (Exception ex)
 3308                {
 3309                    self.core.TrySetException(ex);
 3310                    return;
 3311                }
 3312
 3313                if (Interlocked.Increment(ref self.completedCount) == 1)
 3314                {
 3315                    self.core.TrySetResult((10, default, default, default, default, default, default, default, default, 
 3316                }
 3317            }
 3318
 3319            static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> self,
 3320            {
 3321                T12 result;
 3322                try
 3323                {
 3324                    result = awaiter.GetResult();
 3325                }
 3326                catch (Exception ex)
 3327                {
 3328                    self.core.TrySetException(ex);
 3329                    return;
 3330                }
 3331
 3332                if (Interlocked.Increment(ref self.completedCount) == 1)
 3333                {
 3334                    self.core.TrySetResult((11, default, default, default, default, default, default, default, default, 
 3335                }
 3336            }
 3337
 3338
 3339            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8,
 3340            {
 3341                TaskTracker.RemoveTracking(this);
 3342                GC.SuppressFinalize(this);
 3343                return core.GetResult(token);
 3344            }
 3345
 3346            public UniTaskStatus GetStatus(short token)
 3347            {
 3348                return core.GetStatus(token);
 3349            }
 3350
 3351            public void OnCompleted(Action<object> continuation, object state, short token)
 3352            {
 3353                core.OnCompleted(continuation, state, token);
 3354            }
 3355
 3356            public UniTaskStatus UnsafeGetStatus()
 3357            {
 3358                return core.UnsafeGetStatus();
 3359            }
 3360
 3361            void IUniTaskSource.GetResult(short token)
 3362            {
 3363                GetResult(token);
 3364            }
 3365        }
 3366
 3367        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 03368        {
 03369            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 03370        }
 3371
 3372        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : IUniTaskSource<(int, T1 re
 3373        {
 3374            int completedCount;
 3375            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 3376
 3377            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 3378            {
 3379                TaskTracker.TrackActiveTask(this, 3);
 3380
 3381                this.completedCount = 0;
 3382                {
 3383                    var awaiter = task1.GetAwaiter();
 3384
 3385                    if (awaiter.IsCompleted)
 3386                    {
 3387                        TryInvokeContinuationT1(this, awaiter);
 3388                    }
 3389                    else
 3390                    {
 3391                        awaiter.SourceOnCompleted(state =>
 3392                        {
 3393                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3394                            {
 3395                                TryInvokeContinuationT1(t.Item1, t.Item2);
 3396                            }
 3397                        }, StateTuple.Create(this, awaiter));
 3398                    }
 3399                }
 3400                {
 3401                    var awaiter = task2.GetAwaiter();
 3402
 3403                    if (awaiter.IsCompleted)
 3404                    {
 3405                        TryInvokeContinuationT2(this, awaiter);
 3406                    }
 3407                    else
 3408                    {
 3409                        awaiter.SourceOnCompleted(state =>
 3410                        {
 3411                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3412                            {
 3413                                TryInvokeContinuationT2(t.Item1, t.Item2);
 3414                            }
 3415                        }, StateTuple.Create(this, awaiter));
 3416                    }
 3417                }
 3418                {
 3419                    var awaiter = task3.GetAwaiter();
 3420
 3421                    if (awaiter.IsCompleted)
 3422                    {
 3423                        TryInvokeContinuationT3(this, awaiter);
 3424                    }
 3425                    else
 3426                    {
 3427                        awaiter.SourceOnCompleted(state =>
 3428                        {
 3429                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3430                            {
 3431                                TryInvokeContinuationT3(t.Item1, t.Item2);
 3432                            }
 3433                        }, StateTuple.Create(this, awaiter));
 3434                    }
 3435                }
 3436                {
 3437                    var awaiter = task4.GetAwaiter();
 3438
 3439                    if (awaiter.IsCompleted)
 3440                    {
 3441                        TryInvokeContinuationT4(this, awaiter);
 3442                    }
 3443                    else
 3444                    {
 3445                        awaiter.SourceOnCompleted(state =>
 3446                        {
 3447                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3448                            {
 3449                                TryInvokeContinuationT4(t.Item1, t.Item2);
 3450                            }
 3451                        }, StateTuple.Create(this, awaiter));
 3452                    }
 3453                }
 3454                {
 3455                    var awaiter = task5.GetAwaiter();
 3456
 3457                    if (awaiter.IsCompleted)
 3458                    {
 3459                        TryInvokeContinuationT5(this, awaiter);
 3460                    }
 3461                    else
 3462                    {
 3463                        awaiter.SourceOnCompleted(state =>
 3464                        {
 3465                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3466                            {
 3467                                TryInvokeContinuationT5(t.Item1, t.Item2);
 3468                            }
 3469                        }, StateTuple.Create(this, awaiter));
 3470                    }
 3471                }
 3472                {
 3473                    var awaiter = task6.GetAwaiter();
 3474
 3475                    if (awaiter.IsCompleted)
 3476                    {
 3477                        TryInvokeContinuationT6(this, awaiter);
 3478                    }
 3479                    else
 3480                    {
 3481                        awaiter.SourceOnCompleted(state =>
 3482                        {
 3483                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3484                            {
 3485                                TryInvokeContinuationT6(t.Item1, t.Item2);
 3486                            }
 3487                        }, StateTuple.Create(this, awaiter));
 3488                    }
 3489                }
 3490                {
 3491                    var awaiter = task7.GetAwaiter();
 3492
 3493                    if (awaiter.IsCompleted)
 3494                    {
 3495                        TryInvokeContinuationT7(this, awaiter);
 3496                    }
 3497                    else
 3498                    {
 3499                        awaiter.SourceOnCompleted(state =>
 3500                        {
 3501                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3502                            {
 3503                                TryInvokeContinuationT7(t.Item1, t.Item2);
 3504                            }
 3505                        }, StateTuple.Create(this, awaiter));
 3506                    }
 3507                }
 3508                {
 3509                    var awaiter = task8.GetAwaiter();
 3510
 3511                    if (awaiter.IsCompleted)
 3512                    {
 3513                        TryInvokeContinuationT8(this, awaiter);
 3514                    }
 3515                    else
 3516                    {
 3517                        awaiter.SourceOnCompleted(state =>
 3518                        {
 3519                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3520                            {
 3521                                TryInvokeContinuationT8(t.Item1, t.Item2);
 3522                            }
 3523                        }, StateTuple.Create(this, awaiter));
 3524                    }
 3525                }
 3526                {
 3527                    var awaiter = task9.GetAwaiter();
 3528
 3529                    if (awaiter.IsCompleted)
 3530                    {
 3531                        TryInvokeContinuationT9(this, awaiter);
 3532                    }
 3533                    else
 3534                    {
 3535                        awaiter.SourceOnCompleted(state =>
 3536                        {
 3537                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3538                            {
 3539                                TryInvokeContinuationT9(t.Item1, t.Item2);
 3540                            }
 3541                        }, StateTuple.Create(this, awaiter));
 3542                    }
 3543                }
 3544                {
 3545                    var awaiter = task10.GetAwaiter();
 3546
 3547                    if (awaiter.IsCompleted)
 3548                    {
 3549                        TryInvokeContinuationT10(this, awaiter);
 3550                    }
 3551                    else
 3552                    {
 3553                        awaiter.SourceOnCompleted(state =>
 3554                        {
 3555                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3556                            {
 3557                                TryInvokeContinuationT10(t.Item1, t.Item2);
 3558                            }
 3559                        }, StateTuple.Create(this, awaiter));
 3560                    }
 3561                }
 3562                {
 3563                    var awaiter = task11.GetAwaiter();
 3564
 3565                    if (awaiter.IsCompleted)
 3566                    {
 3567                        TryInvokeContinuationT11(this, awaiter);
 3568                    }
 3569                    else
 3570                    {
 3571                        awaiter.SourceOnCompleted(state =>
 3572                        {
 3573                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3574                            {
 3575                                TryInvokeContinuationT11(t.Item1, t.Item2);
 3576                            }
 3577                        }, StateTuple.Create(this, awaiter));
 3578                    }
 3579                }
 3580                {
 3581                    var awaiter = task12.GetAwaiter();
 3582
 3583                    if (awaiter.IsCompleted)
 3584                    {
 3585                        TryInvokeContinuationT12(this, awaiter);
 3586                    }
 3587                    else
 3588                    {
 3589                        awaiter.SourceOnCompleted(state =>
 3590                        {
 3591                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3592                            {
 3593                                TryInvokeContinuationT12(t.Item1, t.Item2);
 3594                            }
 3595                        }, StateTuple.Create(this, awaiter));
 3596                    }
 3597                }
 3598                {
 3599                    var awaiter = task13.GetAwaiter();
 3600
 3601                    if (awaiter.IsCompleted)
 3602                    {
 3603                        TryInvokeContinuationT13(this, awaiter);
 3604                    }
 3605                    else
 3606                    {
 3607                        awaiter.SourceOnCompleted(state =>
 3608                        {
 3609                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3610                            {
 3611                                TryInvokeContinuationT13(t.Item1, t.Item2);
 3612                            }
 3613                        }, StateTuple.Create(this, awaiter));
 3614                    }
 3615                }
 3616            }
 3617
 3618            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3619            {
 3620                T1 result;
 3621                try
 3622                {
 3623                    result = awaiter.GetResult();
 3624                }
 3625                catch (Exception ex)
 3626                {
 3627                    self.core.TrySetException(ex);
 3628                    return;
 3629                }
 3630
 3631                if (Interlocked.Increment(ref self.completedCount) == 1)
 3632                {
 3633                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default, de
 3634                }
 3635            }
 3636
 3637            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3638            {
 3639                T2 result;
 3640                try
 3641                {
 3642                    result = awaiter.GetResult();
 3643                }
 3644                catch (Exception ex)
 3645                {
 3646                    self.core.TrySetException(ex);
 3647                    return;
 3648                }
 3649
 3650                if (Interlocked.Increment(ref self.completedCount) == 1)
 3651                {
 3652                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default, de
 3653                }
 3654            }
 3655
 3656            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3657            {
 3658                T3 result;
 3659                try
 3660                {
 3661                    result = awaiter.GetResult();
 3662                }
 3663                catch (Exception ex)
 3664                {
 3665                    self.core.TrySetException(ex);
 3666                    return;
 3667                }
 3668
 3669                if (Interlocked.Increment(ref self.completedCount) == 1)
 3670                {
 3671                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default, de
 3672                }
 3673            }
 3674
 3675            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3676            {
 3677                T4 result;
 3678                try
 3679                {
 3680                    result = awaiter.GetResult();
 3681                }
 3682                catch (Exception ex)
 3683                {
 3684                    self.core.TrySetException(ex);
 3685                    return;
 3686                }
 3687
 3688                if (Interlocked.Increment(ref self.completedCount) == 1)
 3689                {
 3690                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default, de
 3691                }
 3692            }
 3693
 3694            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3695            {
 3696                T5 result;
 3697                try
 3698                {
 3699                    result = awaiter.GetResult();
 3700                }
 3701                catch (Exception ex)
 3702                {
 3703                    self.core.TrySetException(ex);
 3704                    return;
 3705                }
 3706
 3707                if (Interlocked.Increment(ref self.completedCount) == 1)
 3708                {
 3709                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default, de
 3710                }
 3711            }
 3712
 3713            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3714            {
 3715                T6 result;
 3716                try
 3717                {
 3718                    result = awaiter.GetResult();
 3719                }
 3720                catch (Exception ex)
 3721                {
 3722                    self.core.TrySetException(ex);
 3723                    return;
 3724                }
 3725
 3726                if (Interlocked.Increment(ref self.completedCount) == 1)
 3727                {
 3728                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default, de
 3729                }
 3730            }
 3731
 3732            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3733            {
 3734                T7 result;
 3735                try
 3736                {
 3737                    result = awaiter.GetResult();
 3738                }
 3739                catch (Exception ex)
 3740                {
 3741                    self.core.TrySetException(ex);
 3742                    return;
 3743                }
 3744
 3745                if (Interlocked.Increment(ref self.completedCount) == 1)
 3746                {
 3747                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default, de
 3748                }
 3749            }
 3750
 3751            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3752            {
 3753                T8 result;
 3754                try
 3755                {
 3756                    result = awaiter.GetResult();
 3757                }
 3758                catch (Exception ex)
 3759                {
 3760                    self.core.TrySetException(ex);
 3761                    return;
 3762                }
 3763
 3764                if (Interlocked.Increment(ref self.completedCount) == 1)
 3765                {
 3766                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result, de
 3767                }
 3768            }
 3769
 3770            static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> s
 3771            {
 3772                T9 result;
 3773                try
 3774                {
 3775                    result = awaiter.GetResult();
 3776                }
 3777                catch (Exception ex)
 3778                {
 3779                    self.core.TrySetException(ex);
 3780                    return;
 3781                }
 3782
 3783                if (Interlocked.Increment(ref self.completedCount) == 1)
 3784                {
 3785                    self.core.TrySetResult((8, default, default, default, default, default, default, default, default, r
 3786                }
 3787            }
 3788
 3789            static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3790            {
 3791                T10 result;
 3792                try
 3793                {
 3794                    result = awaiter.GetResult();
 3795                }
 3796                catch (Exception ex)
 3797                {
 3798                    self.core.TrySetException(ex);
 3799                    return;
 3800                }
 3801
 3802                if (Interlocked.Increment(ref self.completedCount) == 1)
 3803                {
 3804                    self.core.TrySetResult((9, default, default, default, default, default, default, default, default, d
 3805                }
 3806            }
 3807
 3808            static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3809            {
 3810                T11 result;
 3811                try
 3812                {
 3813                    result = awaiter.GetResult();
 3814                }
 3815                catch (Exception ex)
 3816                {
 3817                    self.core.TrySetException(ex);
 3818                    return;
 3819                }
 3820
 3821                if (Interlocked.Increment(ref self.completedCount) == 1)
 3822                {
 3823                    self.core.TrySetResult((10, default, default, default, default, default, default, default, default, 
 3824                }
 3825            }
 3826
 3827            static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3828            {
 3829                T12 result;
 3830                try
 3831                {
 3832                    result = awaiter.GetResult();
 3833                }
 3834                catch (Exception ex)
 3835                {
 3836                    self.core.TrySetException(ex);
 3837                    return;
 3838                }
 3839
 3840                if (Interlocked.Increment(ref self.completedCount) == 1)
 3841                {
 3842                    self.core.TrySetResult((11, default, default, default, default, default, default, default, default, 
 3843                }
 3844            }
 3845
 3846            static void TryInvokeContinuationT13(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> 
 3847            {
 3848                T13 result;
 3849                try
 3850                {
 3851                    result = awaiter.GetResult();
 3852                }
 3853                catch (Exception ex)
 3854                {
 3855                    self.core.TrySetException(ex);
 3856                    return;
 3857                }
 3858
 3859                if (Interlocked.Increment(ref self.completedCount) == 1)
 3860                {
 3861                    self.core.TrySetResult((12, default, default, default, default, default, default, default, default, 
 3862                }
 3863            }
 3864
 3865
 3866            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8,
 3867            {
 3868                TaskTracker.RemoveTracking(this);
 3869                GC.SuppressFinalize(this);
 3870                return core.GetResult(token);
 3871            }
 3872
 3873            public UniTaskStatus GetStatus(short token)
 3874            {
 3875                return core.GetStatus(token);
 3876            }
 3877
 3878            public void OnCompleted(Action<object> continuation, object state, short token)
 3879            {
 3880                core.OnCompleted(continuation, state, token);
 3881            }
 3882
 3883            public UniTaskStatus UnsafeGetStatus()
 3884            {
 3885                return core.UnsafeGetStatus();
 3886            }
 3887
 3888            void IUniTaskSource.GetResult(short token)
 3889            {
 3890                GetResult(token);
 3891            }
 3892        }
 3893
 3894        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 03895        {
 03896            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 03897        }
 3898
 3899        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : IUniTaskSource<(int, 
 3900        {
 3901            int completedCount;
 3902            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 3903
 3904            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 3905            {
 3906                TaskTracker.TrackActiveTask(this, 3);
 3907
 3908                this.completedCount = 0;
 3909                {
 3910                    var awaiter = task1.GetAwaiter();
 3911
 3912                    if (awaiter.IsCompleted)
 3913                    {
 3914                        TryInvokeContinuationT1(this, awaiter);
 3915                    }
 3916                    else
 3917                    {
 3918                        awaiter.SourceOnCompleted(state =>
 3919                        {
 3920                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3921                            {
 3922                                TryInvokeContinuationT1(t.Item1, t.Item2);
 3923                            }
 3924                        }, StateTuple.Create(this, awaiter));
 3925                    }
 3926                }
 3927                {
 3928                    var awaiter = task2.GetAwaiter();
 3929
 3930                    if (awaiter.IsCompleted)
 3931                    {
 3932                        TryInvokeContinuationT2(this, awaiter);
 3933                    }
 3934                    else
 3935                    {
 3936                        awaiter.SourceOnCompleted(state =>
 3937                        {
 3938                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3939                            {
 3940                                TryInvokeContinuationT2(t.Item1, t.Item2);
 3941                            }
 3942                        }, StateTuple.Create(this, awaiter));
 3943                    }
 3944                }
 3945                {
 3946                    var awaiter = task3.GetAwaiter();
 3947
 3948                    if (awaiter.IsCompleted)
 3949                    {
 3950                        TryInvokeContinuationT3(this, awaiter);
 3951                    }
 3952                    else
 3953                    {
 3954                        awaiter.SourceOnCompleted(state =>
 3955                        {
 3956                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3957                            {
 3958                                TryInvokeContinuationT3(t.Item1, t.Item2);
 3959                            }
 3960                        }, StateTuple.Create(this, awaiter));
 3961                    }
 3962                }
 3963                {
 3964                    var awaiter = task4.GetAwaiter();
 3965
 3966                    if (awaiter.IsCompleted)
 3967                    {
 3968                        TryInvokeContinuationT4(this, awaiter);
 3969                    }
 3970                    else
 3971                    {
 3972                        awaiter.SourceOnCompleted(state =>
 3973                        {
 3974                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3975                            {
 3976                                TryInvokeContinuationT4(t.Item1, t.Item2);
 3977                            }
 3978                        }, StateTuple.Create(this, awaiter));
 3979                    }
 3980                }
 3981                {
 3982                    var awaiter = task5.GetAwaiter();
 3983
 3984                    if (awaiter.IsCompleted)
 3985                    {
 3986                        TryInvokeContinuationT5(this, awaiter);
 3987                    }
 3988                    else
 3989                    {
 3990                        awaiter.SourceOnCompleted(state =>
 3991                        {
 3992                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 3993                            {
 3994                                TryInvokeContinuationT5(t.Item1, t.Item2);
 3995                            }
 3996                        }, StateTuple.Create(this, awaiter));
 3997                    }
 3998                }
 3999                {
 4000                    var awaiter = task6.GetAwaiter();
 4001
 4002                    if (awaiter.IsCompleted)
 4003                    {
 4004                        TryInvokeContinuationT6(this, awaiter);
 4005                    }
 4006                    else
 4007                    {
 4008                        awaiter.SourceOnCompleted(state =>
 4009                        {
 4010                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4011                            {
 4012                                TryInvokeContinuationT6(t.Item1, t.Item2);
 4013                            }
 4014                        }, StateTuple.Create(this, awaiter));
 4015                    }
 4016                }
 4017                {
 4018                    var awaiter = task7.GetAwaiter();
 4019
 4020                    if (awaiter.IsCompleted)
 4021                    {
 4022                        TryInvokeContinuationT7(this, awaiter);
 4023                    }
 4024                    else
 4025                    {
 4026                        awaiter.SourceOnCompleted(state =>
 4027                        {
 4028                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4029                            {
 4030                                TryInvokeContinuationT7(t.Item1, t.Item2);
 4031                            }
 4032                        }, StateTuple.Create(this, awaiter));
 4033                    }
 4034                }
 4035                {
 4036                    var awaiter = task8.GetAwaiter();
 4037
 4038                    if (awaiter.IsCompleted)
 4039                    {
 4040                        TryInvokeContinuationT8(this, awaiter);
 4041                    }
 4042                    else
 4043                    {
 4044                        awaiter.SourceOnCompleted(state =>
 4045                        {
 4046                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4047                            {
 4048                                TryInvokeContinuationT8(t.Item1, t.Item2);
 4049                            }
 4050                        }, StateTuple.Create(this, awaiter));
 4051                    }
 4052                }
 4053                {
 4054                    var awaiter = task9.GetAwaiter();
 4055
 4056                    if (awaiter.IsCompleted)
 4057                    {
 4058                        TryInvokeContinuationT9(this, awaiter);
 4059                    }
 4060                    else
 4061                    {
 4062                        awaiter.SourceOnCompleted(state =>
 4063                        {
 4064                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4065                            {
 4066                                TryInvokeContinuationT9(t.Item1, t.Item2);
 4067                            }
 4068                        }, StateTuple.Create(this, awaiter));
 4069                    }
 4070                }
 4071                {
 4072                    var awaiter = task10.GetAwaiter();
 4073
 4074                    if (awaiter.IsCompleted)
 4075                    {
 4076                        TryInvokeContinuationT10(this, awaiter);
 4077                    }
 4078                    else
 4079                    {
 4080                        awaiter.SourceOnCompleted(state =>
 4081                        {
 4082                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4083                            {
 4084                                TryInvokeContinuationT10(t.Item1, t.Item2);
 4085                            }
 4086                        }, StateTuple.Create(this, awaiter));
 4087                    }
 4088                }
 4089                {
 4090                    var awaiter = task11.GetAwaiter();
 4091
 4092                    if (awaiter.IsCompleted)
 4093                    {
 4094                        TryInvokeContinuationT11(this, awaiter);
 4095                    }
 4096                    else
 4097                    {
 4098                        awaiter.SourceOnCompleted(state =>
 4099                        {
 4100                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4101                            {
 4102                                TryInvokeContinuationT11(t.Item1, t.Item2);
 4103                            }
 4104                        }, StateTuple.Create(this, awaiter));
 4105                    }
 4106                }
 4107                {
 4108                    var awaiter = task12.GetAwaiter();
 4109
 4110                    if (awaiter.IsCompleted)
 4111                    {
 4112                        TryInvokeContinuationT12(this, awaiter);
 4113                    }
 4114                    else
 4115                    {
 4116                        awaiter.SourceOnCompleted(state =>
 4117                        {
 4118                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4119                            {
 4120                                TryInvokeContinuationT12(t.Item1, t.Item2);
 4121                            }
 4122                        }, StateTuple.Create(this, awaiter));
 4123                    }
 4124                }
 4125                {
 4126                    var awaiter = task13.GetAwaiter();
 4127
 4128                    if (awaiter.IsCompleted)
 4129                    {
 4130                        TryInvokeContinuationT13(this, awaiter);
 4131                    }
 4132                    else
 4133                    {
 4134                        awaiter.SourceOnCompleted(state =>
 4135                        {
 4136                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4137                            {
 4138                                TryInvokeContinuationT13(t.Item1, t.Item2);
 4139                            }
 4140                        }, StateTuple.Create(this, awaiter));
 4141                    }
 4142                }
 4143                {
 4144                    var awaiter = task14.GetAwaiter();
 4145
 4146                    if (awaiter.IsCompleted)
 4147                    {
 4148                        TryInvokeContinuationT14(this, awaiter);
 4149                    }
 4150                    else
 4151                    {
 4152                        awaiter.SourceOnCompleted(state =>
 4153                        {
 4154                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4155                            {
 4156                                TryInvokeContinuationT14(t.Item1, t.Item2);
 4157                            }
 4158                        }, StateTuple.Create(this, awaiter));
 4159                    }
 4160                }
 4161            }
 4162
 4163            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4164            {
 4165                T1 result;
 4166                try
 4167                {
 4168                    result = awaiter.GetResult();
 4169                }
 4170                catch (Exception ex)
 4171                {
 4172                    self.core.TrySetException(ex);
 4173                    return;
 4174                }
 4175
 4176                if (Interlocked.Increment(ref self.completedCount) == 1)
 4177                {
 4178                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default, de
 4179                }
 4180            }
 4181
 4182            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4183            {
 4184                T2 result;
 4185                try
 4186                {
 4187                    result = awaiter.GetResult();
 4188                }
 4189                catch (Exception ex)
 4190                {
 4191                    self.core.TrySetException(ex);
 4192                    return;
 4193                }
 4194
 4195                if (Interlocked.Increment(ref self.completedCount) == 1)
 4196                {
 4197                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default, de
 4198                }
 4199            }
 4200
 4201            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4202            {
 4203                T3 result;
 4204                try
 4205                {
 4206                    result = awaiter.GetResult();
 4207                }
 4208                catch (Exception ex)
 4209                {
 4210                    self.core.TrySetException(ex);
 4211                    return;
 4212                }
 4213
 4214                if (Interlocked.Increment(ref self.completedCount) == 1)
 4215                {
 4216                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default, de
 4217                }
 4218            }
 4219
 4220            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4221            {
 4222                T4 result;
 4223                try
 4224                {
 4225                    result = awaiter.GetResult();
 4226                }
 4227                catch (Exception ex)
 4228                {
 4229                    self.core.TrySetException(ex);
 4230                    return;
 4231                }
 4232
 4233                if (Interlocked.Increment(ref self.completedCount) == 1)
 4234                {
 4235                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default, de
 4236                }
 4237            }
 4238
 4239            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4240            {
 4241                T5 result;
 4242                try
 4243                {
 4244                    result = awaiter.GetResult();
 4245                }
 4246                catch (Exception ex)
 4247                {
 4248                    self.core.TrySetException(ex);
 4249                    return;
 4250                }
 4251
 4252                if (Interlocked.Increment(ref self.completedCount) == 1)
 4253                {
 4254                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default, de
 4255                }
 4256            }
 4257
 4258            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4259            {
 4260                T6 result;
 4261                try
 4262                {
 4263                    result = awaiter.GetResult();
 4264                }
 4265                catch (Exception ex)
 4266                {
 4267                    self.core.TrySetException(ex);
 4268                    return;
 4269                }
 4270
 4271                if (Interlocked.Increment(ref self.completedCount) == 1)
 4272                {
 4273                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default, de
 4274                }
 4275            }
 4276
 4277            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4278            {
 4279                T7 result;
 4280                try
 4281                {
 4282                    result = awaiter.GetResult();
 4283                }
 4284                catch (Exception ex)
 4285                {
 4286                    self.core.TrySetException(ex);
 4287                    return;
 4288                }
 4289
 4290                if (Interlocked.Increment(ref self.completedCount) == 1)
 4291                {
 4292                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default, de
 4293                }
 4294            }
 4295
 4296            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4297            {
 4298                T8 result;
 4299                try
 4300                {
 4301                    result = awaiter.GetResult();
 4302                }
 4303                catch (Exception ex)
 4304                {
 4305                    self.core.TrySetException(ex);
 4306                    return;
 4307                }
 4308
 4309                if (Interlocked.Increment(ref self.completedCount) == 1)
 4310                {
 4311                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result, de
 4312                }
 4313            }
 4314
 4315            static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4316            {
 4317                T9 result;
 4318                try
 4319                {
 4320                    result = awaiter.GetResult();
 4321                }
 4322                catch (Exception ex)
 4323                {
 4324                    self.core.TrySetException(ex);
 4325                    return;
 4326                }
 4327
 4328                if (Interlocked.Increment(ref self.completedCount) == 1)
 4329                {
 4330                    self.core.TrySetResult((8, default, default, default, default, default, default, default, default, r
 4331                }
 4332            }
 4333
 4334            static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4335            {
 4336                T10 result;
 4337                try
 4338                {
 4339                    result = awaiter.GetResult();
 4340                }
 4341                catch (Exception ex)
 4342                {
 4343                    self.core.TrySetException(ex);
 4344                    return;
 4345                }
 4346
 4347                if (Interlocked.Increment(ref self.completedCount) == 1)
 4348                {
 4349                    self.core.TrySetResult((9, default, default, default, default, default, default, default, default, d
 4350                }
 4351            }
 4352
 4353            static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4354            {
 4355                T11 result;
 4356                try
 4357                {
 4358                    result = awaiter.GetResult();
 4359                }
 4360                catch (Exception ex)
 4361                {
 4362                    self.core.TrySetException(ex);
 4363                    return;
 4364                }
 4365
 4366                if (Interlocked.Increment(ref self.completedCount) == 1)
 4367                {
 4368                    self.core.TrySetResult((10, default, default, default, default, default, default, default, default, 
 4369                }
 4370            }
 4371
 4372            static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4373            {
 4374                T12 result;
 4375                try
 4376                {
 4377                    result = awaiter.GetResult();
 4378                }
 4379                catch (Exception ex)
 4380                {
 4381                    self.core.TrySetException(ex);
 4382                    return;
 4383                }
 4384
 4385                if (Interlocked.Increment(ref self.completedCount) == 1)
 4386                {
 4387                    self.core.TrySetResult((11, default, default, default, default, default, default, default, default, 
 4388                }
 4389            }
 4390
 4391            static void TryInvokeContinuationT13(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4392            {
 4393                T13 result;
 4394                try
 4395                {
 4396                    result = awaiter.GetResult();
 4397                }
 4398                catch (Exception ex)
 4399                {
 4400                    self.core.TrySetException(ex);
 4401                    return;
 4402                }
 4403
 4404                if (Interlocked.Increment(ref self.completedCount) == 1)
 4405                {
 4406                    self.core.TrySetResult((12, default, default, default, default, default, default, default, default, 
 4407                }
 4408            }
 4409
 4410            static void TryInvokeContinuationT14(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4411            {
 4412                T14 result;
 4413                try
 4414                {
 4415                    result = awaiter.GetResult();
 4416                }
 4417                catch (Exception ex)
 4418                {
 4419                    self.core.TrySetException(ex);
 4420                    return;
 4421                }
 4422
 4423                if (Interlocked.Increment(ref self.completedCount) == 1)
 4424                {
 4425                    self.core.TrySetResult((13, default, default, default, default, default, default, default, default, 
 4426                }
 4427            }
 4428
 4429
 4430            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8,
 4431            {
 4432                TaskTracker.RemoveTracking(this);
 4433                GC.SuppressFinalize(this);
 4434                return core.GetResult(token);
 4435            }
 4436
 4437            public UniTaskStatus GetStatus(short token)
 4438            {
 4439                return core.GetStatus(token);
 4440            }
 4441
 4442            public void OnCompleted(Action<object> continuation, object state, short token)
 4443            {
 4444                core.OnCompleted(continuation, state, token);
 4445            }
 4446
 4447            public UniTaskStatus UnsafeGetStatus()
 4448            {
 4449                return core.UnsafeGetStatus();
 4450            }
 4451
 4452            void IUniTaskSource.GetResult(short token)
 4453            {
 4454                GetResult(token);
 4455            }
 4456        }
 4457
 4458        public static UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 resu
 04459        {
 04460            return new UniTask<(int winArgumentIndex, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 res
 04461        }
 4462
 4463        sealed class WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : IUniTaskSource<(
 4464        {
 4465            int completedCount;
 4466            UniTaskCompletionSourceCore<(int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7
 4467
 4468            public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5
 4469            {
 4470                TaskTracker.TrackActiveTask(this, 3);
 4471
 4472                this.completedCount = 0;
 4473                {
 4474                    var awaiter = task1.GetAwaiter();
 4475
 4476                    if (awaiter.IsCompleted)
 4477                    {
 4478                        TryInvokeContinuationT1(this, awaiter);
 4479                    }
 4480                    else
 4481                    {
 4482                        awaiter.SourceOnCompleted(state =>
 4483                        {
 4484                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4485                            {
 4486                                TryInvokeContinuationT1(t.Item1, t.Item2);
 4487                            }
 4488                        }, StateTuple.Create(this, awaiter));
 4489                    }
 4490                }
 4491                {
 4492                    var awaiter = task2.GetAwaiter();
 4493
 4494                    if (awaiter.IsCompleted)
 4495                    {
 4496                        TryInvokeContinuationT2(this, awaiter);
 4497                    }
 4498                    else
 4499                    {
 4500                        awaiter.SourceOnCompleted(state =>
 4501                        {
 4502                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4503                            {
 4504                                TryInvokeContinuationT2(t.Item1, t.Item2);
 4505                            }
 4506                        }, StateTuple.Create(this, awaiter));
 4507                    }
 4508                }
 4509                {
 4510                    var awaiter = task3.GetAwaiter();
 4511
 4512                    if (awaiter.IsCompleted)
 4513                    {
 4514                        TryInvokeContinuationT3(this, awaiter);
 4515                    }
 4516                    else
 4517                    {
 4518                        awaiter.SourceOnCompleted(state =>
 4519                        {
 4520                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4521                            {
 4522                                TryInvokeContinuationT3(t.Item1, t.Item2);
 4523                            }
 4524                        }, StateTuple.Create(this, awaiter));
 4525                    }
 4526                }
 4527                {
 4528                    var awaiter = task4.GetAwaiter();
 4529
 4530                    if (awaiter.IsCompleted)
 4531                    {
 4532                        TryInvokeContinuationT4(this, awaiter);
 4533                    }
 4534                    else
 4535                    {
 4536                        awaiter.SourceOnCompleted(state =>
 4537                        {
 4538                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4539                            {
 4540                                TryInvokeContinuationT4(t.Item1, t.Item2);
 4541                            }
 4542                        }, StateTuple.Create(this, awaiter));
 4543                    }
 4544                }
 4545                {
 4546                    var awaiter = task5.GetAwaiter();
 4547
 4548                    if (awaiter.IsCompleted)
 4549                    {
 4550                        TryInvokeContinuationT5(this, awaiter);
 4551                    }
 4552                    else
 4553                    {
 4554                        awaiter.SourceOnCompleted(state =>
 4555                        {
 4556                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4557                            {
 4558                                TryInvokeContinuationT5(t.Item1, t.Item2);
 4559                            }
 4560                        }, StateTuple.Create(this, awaiter));
 4561                    }
 4562                }
 4563                {
 4564                    var awaiter = task6.GetAwaiter();
 4565
 4566                    if (awaiter.IsCompleted)
 4567                    {
 4568                        TryInvokeContinuationT6(this, awaiter);
 4569                    }
 4570                    else
 4571                    {
 4572                        awaiter.SourceOnCompleted(state =>
 4573                        {
 4574                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4575                            {
 4576                                TryInvokeContinuationT6(t.Item1, t.Item2);
 4577                            }
 4578                        }, StateTuple.Create(this, awaiter));
 4579                    }
 4580                }
 4581                {
 4582                    var awaiter = task7.GetAwaiter();
 4583
 4584                    if (awaiter.IsCompleted)
 4585                    {
 4586                        TryInvokeContinuationT7(this, awaiter);
 4587                    }
 4588                    else
 4589                    {
 4590                        awaiter.SourceOnCompleted(state =>
 4591                        {
 4592                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4593                            {
 4594                                TryInvokeContinuationT7(t.Item1, t.Item2);
 4595                            }
 4596                        }, StateTuple.Create(this, awaiter));
 4597                    }
 4598                }
 4599                {
 4600                    var awaiter = task8.GetAwaiter();
 4601
 4602                    if (awaiter.IsCompleted)
 4603                    {
 4604                        TryInvokeContinuationT8(this, awaiter);
 4605                    }
 4606                    else
 4607                    {
 4608                        awaiter.SourceOnCompleted(state =>
 4609                        {
 4610                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4611                            {
 4612                                TryInvokeContinuationT8(t.Item1, t.Item2);
 4613                            }
 4614                        }, StateTuple.Create(this, awaiter));
 4615                    }
 4616                }
 4617                {
 4618                    var awaiter = task9.GetAwaiter();
 4619
 4620                    if (awaiter.IsCompleted)
 4621                    {
 4622                        TryInvokeContinuationT9(this, awaiter);
 4623                    }
 4624                    else
 4625                    {
 4626                        awaiter.SourceOnCompleted(state =>
 4627                        {
 4628                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4629                            {
 4630                                TryInvokeContinuationT9(t.Item1, t.Item2);
 4631                            }
 4632                        }, StateTuple.Create(this, awaiter));
 4633                    }
 4634                }
 4635                {
 4636                    var awaiter = task10.GetAwaiter();
 4637
 4638                    if (awaiter.IsCompleted)
 4639                    {
 4640                        TryInvokeContinuationT10(this, awaiter);
 4641                    }
 4642                    else
 4643                    {
 4644                        awaiter.SourceOnCompleted(state =>
 4645                        {
 4646                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4647                            {
 4648                                TryInvokeContinuationT10(t.Item1, t.Item2);
 4649                            }
 4650                        }, StateTuple.Create(this, awaiter));
 4651                    }
 4652                }
 4653                {
 4654                    var awaiter = task11.GetAwaiter();
 4655
 4656                    if (awaiter.IsCompleted)
 4657                    {
 4658                        TryInvokeContinuationT11(this, awaiter);
 4659                    }
 4660                    else
 4661                    {
 4662                        awaiter.SourceOnCompleted(state =>
 4663                        {
 4664                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4665                            {
 4666                                TryInvokeContinuationT11(t.Item1, t.Item2);
 4667                            }
 4668                        }, StateTuple.Create(this, awaiter));
 4669                    }
 4670                }
 4671                {
 4672                    var awaiter = task12.GetAwaiter();
 4673
 4674                    if (awaiter.IsCompleted)
 4675                    {
 4676                        TryInvokeContinuationT12(this, awaiter);
 4677                    }
 4678                    else
 4679                    {
 4680                        awaiter.SourceOnCompleted(state =>
 4681                        {
 4682                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4683                            {
 4684                                TryInvokeContinuationT12(t.Item1, t.Item2);
 4685                            }
 4686                        }, StateTuple.Create(this, awaiter));
 4687                    }
 4688                }
 4689                {
 4690                    var awaiter = task13.GetAwaiter();
 4691
 4692                    if (awaiter.IsCompleted)
 4693                    {
 4694                        TryInvokeContinuationT13(this, awaiter);
 4695                    }
 4696                    else
 4697                    {
 4698                        awaiter.SourceOnCompleted(state =>
 4699                        {
 4700                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4701                            {
 4702                                TryInvokeContinuationT13(t.Item1, t.Item2);
 4703                            }
 4704                        }, StateTuple.Create(this, awaiter));
 4705                    }
 4706                }
 4707                {
 4708                    var awaiter = task14.GetAwaiter();
 4709
 4710                    if (awaiter.IsCompleted)
 4711                    {
 4712                        TryInvokeContinuationT14(this, awaiter);
 4713                    }
 4714                    else
 4715                    {
 4716                        awaiter.SourceOnCompleted(state =>
 4717                        {
 4718                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4719                            {
 4720                                TryInvokeContinuationT14(t.Item1, t.Item2);
 4721                            }
 4722                        }, StateTuple.Create(this, awaiter));
 4723                    }
 4724                }
 4725                {
 4726                    var awaiter = task15.GetAwaiter();
 4727
 4728                    if (awaiter.IsCompleted)
 4729                    {
 4730                        TryInvokeContinuationT15(this, awaiter);
 4731                    }
 4732                    else
 4733                    {
 4734                        awaiter.SourceOnCompleted(state =>
 4735                        {
 4736                            using (var t = (StateTuple<WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
 4737                            {
 4738                                TryInvokeContinuationT15(t.Item1, t.Item2);
 4739                            }
 4740                        }, StateTuple.Create(this, awaiter));
 4741                    }
 4742                }
 4743            }
 4744
 4745            static void TryInvokeContinuationT1(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4746            {
 4747                T1 result;
 4748                try
 4749                {
 4750                    result = awaiter.GetResult();
 4751                }
 4752                catch (Exception ex)
 4753                {
 4754                    self.core.TrySetException(ex);
 4755                    return;
 4756                }
 4757
 4758                if (Interlocked.Increment(ref self.completedCount) == 1)
 4759                {
 4760                    self.core.TrySetResult((0, result, default, default, default, default, default, default, default, de
 4761                }
 4762            }
 4763
 4764            static void TryInvokeContinuationT2(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4765            {
 4766                T2 result;
 4767                try
 4768                {
 4769                    result = awaiter.GetResult();
 4770                }
 4771                catch (Exception ex)
 4772                {
 4773                    self.core.TrySetException(ex);
 4774                    return;
 4775                }
 4776
 4777                if (Interlocked.Increment(ref self.completedCount) == 1)
 4778                {
 4779                    self.core.TrySetResult((1, default, result, default, default, default, default, default, default, de
 4780                }
 4781            }
 4782
 4783            static void TryInvokeContinuationT3(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4784            {
 4785                T3 result;
 4786                try
 4787                {
 4788                    result = awaiter.GetResult();
 4789                }
 4790                catch (Exception ex)
 4791                {
 4792                    self.core.TrySetException(ex);
 4793                    return;
 4794                }
 4795
 4796                if (Interlocked.Increment(ref self.completedCount) == 1)
 4797                {
 4798                    self.core.TrySetResult((2, default, default, result, default, default, default, default, default, de
 4799                }
 4800            }
 4801
 4802            static void TryInvokeContinuationT4(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4803            {
 4804                T4 result;
 4805                try
 4806                {
 4807                    result = awaiter.GetResult();
 4808                }
 4809                catch (Exception ex)
 4810                {
 4811                    self.core.TrySetException(ex);
 4812                    return;
 4813                }
 4814
 4815                if (Interlocked.Increment(ref self.completedCount) == 1)
 4816                {
 4817                    self.core.TrySetResult((3, default, default, default, result, default, default, default, default, de
 4818                }
 4819            }
 4820
 4821            static void TryInvokeContinuationT5(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4822            {
 4823                T5 result;
 4824                try
 4825                {
 4826                    result = awaiter.GetResult();
 4827                }
 4828                catch (Exception ex)
 4829                {
 4830                    self.core.TrySetException(ex);
 4831                    return;
 4832                }
 4833
 4834                if (Interlocked.Increment(ref self.completedCount) == 1)
 4835                {
 4836                    self.core.TrySetResult((4, default, default, default, default, result, default, default, default, de
 4837                }
 4838            }
 4839
 4840            static void TryInvokeContinuationT6(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4841            {
 4842                T6 result;
 4843                try
 4844                {
 4845                    result = awaiter.GetResult();
 4846                }
 4847                catch (Exception ex)
 4848                {
 4849                    self.core.TrySetException(ex);
 4850                    return;
 4851                }
 4852
 4853                if (Interlocked.Increment(ref self.completedCount) == 1)
 4854                {
 4855                    self.core.TrySetResult((5, default, default, default, default, default, result, default, default, de
 4856                }
 4857            }
 4858
 4859            static void TryInvokeContinuationT7(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4860            {
 4861                T7 result;
 4862                try
 4863                {
 4864                    result = awaiter.GetResult();
 4865                }
 4866                catch (Exception ex)
 4867                {
 4868                    self.core.TrySetException(ex);
 4869                    return;
 4870                }
 4871
 4872                if (Interlocked.Increment(ref self.completedCount) == 1)
 4873                {
 4874                    self.core.TrySetResult((6, default, default, default, default, default, default, result, default, de
 4875                }
 4876            }
 4877
 4878            static void TryInvokeContinuationT8(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4879            {
 4880                T8 result;
 4881                try
 4882                {
 4883                    result = awaiter.GetResult();
 4884                }
 4885                catch (Exception ex)
 4886                {
 4887                    self.core.TrySetException(ex);
 4888                    return;
 4889                }
 4890
 4891                if (Interlocked.Increment(ref self.completedCount) == 1)
 4892                {
 4893                    self.core.TrySetResult((7, default, default, default, default, default, default, default, result, de
 4894                }
 4895            }
 4896
 4897            static void TryInvokeContinuationT9(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T
 4898            {
 4899                T9 result;
 4900                try
 4901                {
 4902                    result = awaiter.GetResult();
 4903                }
 4904                catch (Exception ex)
 4905                {
 4906                    self.core.TrySetException(ex);
 4907                    return;
 4908                }
 4909
 4910                if (Interlocked.Increment(ref self.completedCount) == 1)
 4911                {
 4912                    self.core.TrySetResult((8, default, default, default, default, default, default, default, default, r
 4913                }
 4914            }
 4915
 4916            static void TryInvokeContinuationT10(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4917            {
 4918                T10 result;
 4919                try
 4920                {
 4921                    result = awaiter.GetResult();
 4922                }
 4923                catch (Exception ex)
 4924                {
 4925                    self.core.TrySetException(ex);
 4926                    return;
 4927                }
 4928
 4929                if (Interlocked.Increment(ref self.completedCount) == 1)
 4930                {
 4931                    self.core.TrySetResult((9, default, default, default, default, default, default, default, default, d
 4932                }
 4933            }
 4934
 4935            static void TryInvokeContinuationT11(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4936            {
 4937                T11 result;
 4938                try
 4939                {
 4940                    result = awaiter.GetResult();
 4941                }
 4942                catch (Exception ex)
 4943                {
 4944                    self.core.TrySetException(ex);
 4945                    return;
 4946                }
 4947
 4948                if (Interlocked.Increment(ref self.completedCount) == 1)
 4949                {
 4950                    self.core.TrySetResult((10, default, default, default, default, default, default, default, default, 
 4951                }
 4952            }
 4953
 4954            static void TryInvokeContinuationT12(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4955            {
 4956                T12 result;
 4957                try
 4958                {
 4959                    result = awaiter.GetResult();
 4960                }
 4961                catch (Exception ex)
 4962                {
 4963                    self.core.TrySetException(ex);
 4964                    return;
 4965                }
 4966
 4967                if (Interlocked.Increment(ref self.completedCount) == 1)
 4968                {
 4969                    self.core.TrySetResult((11, default, default, default, default, default, default, default, default, 
 4970                }
 4971            }
 4972
 4973            static void TryInvokeContinuationT13(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4974            {
 4975                T13 result;
 4976                try
 4977                {
 4978                    result = awaiter.GetResult();
 4979                }
 4980                catch (Exception ex)
 4981                {
 4982                    self.core.TrySetException(ex);
 4983                    return;
 4984                }
 4985
 4986                if (Interlocked.Increment(ref self.completedCount) == 1)
 4987                {
 4988                    self.core.TrySetResult((12, default, default, default, default, default, default, default, default, 
 4989                }
 4990            }
 4991
 4992            static void TryInvokeContinuationT14(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 4993            {
 4994                T14 result;
 4995                try
 4996                {
 4997                    result = awaiter.GetResult();
 4998                }
 4999                catch (Exception ex)
 5000                {
 5001                    self.core.TrySetException(ex);
 5002                    return;
 5003                }
 5004
 5005                if (Interlocked.Increment(ref self.completedCount) == 1)
 5006                {
 5007                    self.core.TrySetResult((13, default, default, default, default, default, default, default, default, 
 5008                }
 5009            }
 5010
 5011            static void TryInvokeContinuationT15(WhenAnyPromise<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, 
 5012            {
 5013                T15 result;
 5014                try
 5015                {
 5016                    result = awaiter.GetResult();
 5017                }
 5018                catch (Exception ex)
 5019                {
 5020                    self.core.TrySetException(ex);
 5021                    return;
 5022                }
 5023
 5024                if (Interlocked.Increment(ref self.completedCount) == 1)
 5025                {
 5026                    self.core.TrySetResult((14, default, default, default, default, default, default, default, default, 
 5027                }
 5028            }
 5029
 5030
 5031            public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8,
 5032            {
 5033                TaskTracker.RemoveTracking(this);
 5034                GC.SuppressFinalize(this);
 5035                return core.GetResult(token);
 5036            }
 5037
 5038            public UniTaskStatus GetStatus(short token)
 5039            {
 5040                return core.GetStatus(token);
 5041            }
 5042
 5043            public void OnCompleted(Action<object> continuation, object state, short token)
 5044            {
 5045                core.OnCompleted(continuation, state, token);
 5046            }
 5047
 5048            public UniTaskStatus UnsafeGetStatus()
 5049            {
 5050                return core.UnsafeGetStatus();
 5051            }
 5052
 5053            void IUniTaskSource.GetResult(short token)
 5054            {
 5055                GetResult(token);
 5056            }
 5057        }
 5058
 5059    }
 5060}

Methods/Properties

ToCoroutine(System.Func[UniTask])
UniTask(Cysharp.Threading.Tasks.IUniTaskSource, System.Int16)
Status()
GetAwaiter()
SuppressCancellationThrow()
implicit operator System.Threading.Tasks.ValueTask(Cysharp.Threading.Tasks.UniTask&)
ToString()
Preserve()
AsAsyncUnitUniTask()
AsyncUnitSource(Cysharp.Threading.Tasks.IUniTaskSource)
GetResult(System.Int16)
GetStatus(System.Int16)
OnCompleted(System.Action[Object], System.Object, System.Int16)
UnsafeGetStatus()
GetResult(System.Int16)
IsCanceledSource(Cysharp.Threading.Tasks.IUniTaskSource)
GetResult(System.Int16)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MemoizeSource(Cysharp.Threading.Tasks.IUniTaskSource)
GetResult(System.Int16)
GetStatus(System.Int16)
OnCompleted(System.Action[Object], System.Object, System.Int16)
UnsafeGetStatus()
Awaiter(Cysharp.Threading.Tasks.UniTask&)
IsCompleted()
GetResult()
OnCompleted(System.Action)
UnsafeOnCompleted(System.Action)
SourceOnCompleted(System.Action[Object], System.Object)
Yield()
Yield(Cysharp.Threading.Tasks.PlayerLoopTiming)
Yield(System.Threading.CancellationToken, System.Boolean)
Yield(Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
NextFrame()
NextFrame(Cysharp.Threading.Tasks.PlayerLoopTiming)
NextFrame(System.Threading.CancellationToken, System.Boolean)
NextFrame(Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
WaitForEndOfFrame()
WaitForEndOfFrame(System.Threading.CancellationToken, System.Boolean)
WaitForEndOfFrame(UnityEngine.MonoBehaviour)
WaitForEndOfFrame(UnityEngine.MonoBehaviour, System.Threading.CancellationToken, System.Boolean)
WaitForFixedUpdate()
WaitForFixedUpdate(System.Threading.CancellationToken, System.Boolean)
WaitForSeconds(System.Single, System.Boolean, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
WaitForSeconds(System.Int32, System.Boolean, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
DelayFrame(System.Int32, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
Delay(System.Int32, System.Boolean, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
Delay(System.TimeSpan, System.Boolean, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
Delay(System.Int32, Cysharp.Threading.Tasks.DelayType, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
Delay(System.TimeSpan, Cysharp.Threading.Tasks.DelayType, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
NextNode()
YieldPromise()
YieldPromise()
Create(Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
NextNode()
NextFramePromise()
NextFramePromise()
Create(Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
NextNode()
WaitForEndOfFramePromise()
WaitForEndOfFramePromise()
Create(UnityEngine.MonoBehaviour, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
TryReturn()
get_Current()
MoveNext()
Reset()
NextNode()
DelayFramePromise()
DelayFramePromise()
Create(System.Int32, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
NextNode()
DelayPromise()
DelayPromise()
Create(System.TimeSpan, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
NextNode()
DelayIgnoreTimeScalePromise()
DelayIgnoreTimeScalePromise()
Create(System.TimeSpan, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
NextNode()
DelayRealtimePromise()
DelayRealtimePromise()
Create(System.TimeSpan, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
UniTask()
FromException(System.Exception)
FromException[T](System.Exception)
FromResult[T](T)
FromCanceled(System.Threading.CancellationToken)
FromCanceled[T](System.Threading.CancellationToken)
Create(System.Func[UniTask])
Create[T](System.Func[UniTask`1])
Lazy(System.Func[UniTask])
Lazy[T](System.Func[UniTask`1])
Void(System.Func[UniTaskVoid])
Void(System.Func[CancellationToken,UniTaskVoid], System.Threading.CancellationToken)
Void[T](System.Func[T,UniTaskVoid], T)
Action(System.Func[UniTaskVoid])
Action(System.Func[CancellationToken,UniTaskVoid], System.Threading.CancellationToken)
UnityAction(System.Func[UniTaskVoid])
UnityAction(System.Func[CancellationToken,UniTaskVoid], System.Threading.CancellationToken)
Defer(System.Func[UniTask])
Defer[T](System.Func[UniTask`1])
Never(System.Threading.CancellationToken)
Never[T](System.Threading.CancellationToken)
ExceptionResultSource(System.Exception)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
Finalize()
CanceledResultSource(System.Threading.CancellationToken)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
DeferPromise(System.Func[UniTask])
GetResult(System.Int16)
GetStatus(System.Int16)
OnCompleted(System.Action[Object], System.Object, System.Int16)
UnsafeGetStatus()
Run(System.Action, System.Boolean, System.Threading.CancellationToken)
Run(System.Action[Object], System.Object, System.Boolean, System.Threading.CancellationToken)
Run(System.Func[UniTask], System.Boolean, System.Threading.CancellationToken)
Run(System.Func[Object,UniTask], System.Object, System.Boolean, System.Threading.CancellationToken)
Run[T](System.Func[T], System.Boolean, System.Threading.CancellationToken)
Run[T](System.Func[UniTask`1], System.Boolean, System.Threading.CancellationToken)
Run[T](System.Func[Object,T], System.Object, System.Boolean, System.Threading.CancellationToken)
Run[T](System.Func[Object,UniTask`1], System.Object, System.Boolean, System.Threading.CancellationToken)
RunOnThreadPool()
RunOnThreadPool()
RunOnThreadPool()
RunOnThreadPool()
SwitchToMainThread(System.Threading.CancellationToken)
SwitchToMainThread(Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken)
ReturnToMainThread(System.Threading.CancellationToken)
ReturnToMainThread(Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken)
Post(System.Action, Cysharp.Threading.Tasks.PlayerLoopTiming)
SwitchToThreadPool()
SwitchToTaskPool()
SwitchToSynchronizationContext(System.Threading.SynchronizationContext, System.Threading.CancellationToken)
ReturnToSynchronizationContext(System.Threading.SynchronizationContext, System.Threading.CancellationToken)
ReturnToCurrentSynchronizationContext(System.Boolean, System.Threading.CancellationToken)
WaitUntil(System.Func[Boolean], Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
WaitWhile(System.Func[Boolean], Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean)
WaitUntilCanceled(System.Threading.CancellationToken, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Boolean)
WaitUntilValueChanged[T, U](T, System.Func[T,U], Cysharp.Threading.Tasks.PlayerLoopTiming, System.Collections.Generic.IEqualityComparer[U], System.Threading.CancellationToken, System.Boolean)
NextNode()
WaitUntilPromise()
WaitUntilPromise()
Create(System.Func[Boolean], Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
NextNode()
WaitWhilePromise()
WaitWhilePromise()
Create(System.Func[Boolean], Cysharp.Threading.Tasks.PlayerLoopTiming, System.Threading.CancellationToken, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
NextNode()
WaitUntilCanceledPromise()
WaitUntilCanceledPromise()
Create(System.Threading.CancellationToken, Cysharp.Threading.Tasks.PlayerLoopTiming, System.Boolean, System.Int16&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
MoveNext()
TryReturn()
WhenAll[T]()
WhenAll[T](System.Collections.Generic.IEnumerable[UniTask`1])
WhenAll(Cysharp.Threading.Tasks.UniTask[])
WhenAll(System.Collections.Generic.IEnumerable[UniTask])
WhenAllPromise(Cysharp.Threading.Tasks.UniTask[], System.Int32)
TryInvokeContinuation(Cysharp.Threading.Tasks.UniTask/WhenAllPromise, Cysharp.Threading.Tasks.UniTask/Awaiter&)
GetResult(System.Int16)
GetStatus(System.Int16)
UnsafeGetStatus()
OnCompleted(System.Action[Object], System.Object, System.Int16)
WhenAll[T1, T2](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2])
WhenAll[T1, T2, T3](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3])
WhenAll[T1, T2, T3, T4](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4])
WhenAll[T1, T2, T3, T4, T5](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5])
WhenAll[T1, T2, T3, T4, T5, T6](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6])
WhenAll[T1, T2, T3, T4, T5, T6, T7](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12], Cysharp.Threading.Tasks.UniTask[T13])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12], Cysharp.Threading.Tasks.UniTask[T13], Cysharp.Threading.Tasks.UniTask[T14])
WhenAll[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12], Cysharp.Threading.Tasks.UniTask[T13], Cysharp.Threading.Tasks.UniTask[T14], Cysharp.Threading.Tasks.UniTask[T15])
WhenAny[T](Cysharp.Threading.Tasks.UniTask[T], Cysharp.Threading.Tasks.UniTask)
WhenAny[T]()
WhenAny[T](System.Collections.Generic.IEnumerable[UniTask`1])
WhenAny(Cysharp.Threading.Tasks.UniTask[])
WhenAny(System.Collections.Generic.IEnumerable[UniTask])
WhenAnyPromise(Cysharp.Threading.Tasks.UniTask[], System.Int32)
TryInvokeContinuation(Cysharp.Threading.Tasks.UniTask/WhenAnyPromise, Cysharp.Threading.Tasks.UniTask/Awaiter&, System.Int32)
GetResult(System.Int16)
GetStatus(System.Int16)
OnCompleted(System.Action[Object], System.Object, System.Int16)
UnsafeGetStatus()
GetResult(System.Int16)
WhenAny[T1, T2](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2])
WhenAny[T1, T2, T3](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3])
WhenAny[T1, T2, T3, T4](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4])
WhenAny[T1, T2, T3, T4, T5](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5])
WhenAny[T1, T2, T3, T4, T5, T6](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6])
WhenAny[T1, T2, T3, T4, T5, T6, T7](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12], Cysharp.Threading.Tasks.UniTask[T13])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12], Cysharp.Threading.Tasks.UniTask[T13], Cysharp.Threading.Tasks.UniTask[T14])
WhenAny[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](Cysharp.Threading.Tasks.UniTask[T1], Cysharp.Threading.Tasks.UniTask[T2], Cysharp.Threading.Tasks.UniTask[T3], Cysharp.Threading.Tasks.UniTask[T4], Cysharp.Threading.Tasks.UniTask[T5], Cysharp.Threading.Tasks.UniTask[T6], Cysharp.Threading.Tasks.UniTask[T7], Cysharp.Threading.Tasks.UniTask[T8], Cysharp.Threading.Tasks.UniTask[T9], Cysharp.Threading.Tasks.UniTask[T10], Cysharp.Threading.Tasks.UniTask[T11], Cysharp.Threading.Tasks.UniTask[T12], Cysharp.Threading.Tasks.UniTask[T13], Cysharp.Threading.Tasks.UniTask[T14], Cysharp.Threading.Tasks.UniTask[T15])